Skip to content

Commit ce17659

Browse files
committed
fix: set 0 timeout on function exit
1 parent 5127791 commit ce17659

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/cmap/connection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
341341
}
342342

343343
if (!operationDescription) {
344+
this[kStream].setTimeout(0);
344345
return;
345346
}
346347

test/unit/cmap/connection.test.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,8 @@ describe('new Connection()', function () {
482482
opCode: msg.readInt32LE(12)
483483
};
484484
const msgBody = msg.subarray(16);
485-
try {
486-
connection.onMessage(new BinMsg(msg, msgHeader, msgBody));
487-
} catch {
488-
// regardless of outcome
489-
}
485+
msgBody.writeInt32LE(0, 0); // OPTS_MORE_TO_COME
486+
connection.onMessage(new BinMsg(msg, msgHeader, msgBody));
490487
// timeout is still reset
491488
expect(connection.stream).to.have.property('timeout', 0);
492489
});
@@ -501,12 +498,8 @@ describe('new Connection()', function () {
501498
opCode: msg.readInt32LE(12)
502499
};
503500
const msgBody = msg.subarray(16);
504-
msgBody.writeInt32LE(2); // OPTS_MORE_TO_COME
505-
try {
506-
connection.onMessage(new BinMsg(msg, msgHeader, msgBody));
507-
} catch {
508-
// regardless of outcome
509-
}
501+
msgBody.writeInt32LE(2, 0); // OPTS_MORE_TO_COME
502+
connection.onMessage(new BinMsg(msg, msgHeader, msgBody));
510503
// timeout is still set
511504
expect(connection.stream).to.have.property('timeout', 1);
512505
});

0 commit comments

Comments
 (0)