Skip to content

Commit 910dfaf

Browse files
committed
fix: 0 timeout always, reset if moreToCome is set
1 parent ce17659 commit 910dfaf

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/cmap/connection.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
316316
this[kDelayedTimeoutId] = null;
317317
}
318318

319+
const socketTimeoutMS = this[kStream].timeout ?? 0;
320+
this[kStream].setTimeout(0);
321+
319322
// always emit the message, in case we are streaming
320323
this.emit('message', message);
321324
let operationDescription = this[kQueue].get(message.responseTo);
@@ -341,7 +344,6 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
341344
}
342345

343346
if (!operationDescription) {
344-
this[kStream].setTimeout(0);
345347
return;
346348
}
347349

@@ -357,8 +359,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
357359
// back in the queue with the correct requestId and will resolve not being able
358360
// to find the next one via the responseTo of the next streaming hello.
359361
this[kQueue].set(message.requestId, operationDescription);
360-
} else {
361-
this[kStream].setTimeout(0);
362+
this[kStream].setTimeout(socketTimeoutMS);
362363
}
363364

364365
try {

test/unit/cmap/connection.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ describe('new Connection()', function () {
499499
};
500500
const msgBody = msg.subarray(16);
501501
msgBody.writeInt32LE(2, 0); // OPTS_MORE_TO_COME
502+
connection[getSymbolFrom(connection, 'queue')].set(0, { cb: () => null });
502503
connection.onMessage(new BinMsg(msg, msgHeader, msgBody));
503504
// timeout is still set
504505
expect(connection.stream).to.have.property('timeout', 1);

0 commit comments

Comments
 (0)