Skip to content

Commit faec64a

Browse files
fix hangs
1 parent 66b5383 commit faec64a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/cmap/wire_protocol/on_data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export function onData(
116116
emitter.off('data', eventHandler);
117117
emitter.off('error', errorHandler);
118118
finished = true;
119+
timeoutForSocketRead?.clear();
119120
const doneResult = { value: undefined, done: finished } as const;
120121

121122
for (const promise of unconsumedPromises) {

test/integration/client-side-operations-timeout/node_csot.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,16 @@ describe('CSOT driver tests', metadata, () => {
271271
.stub(Connection.prototype, 'readMany')
272272
.callsFake(async function* (...args) {
273273
const realIterator = readManyStub.wrappedMethod.call(this, ...args);
274-
const cmd = commandSpy.lastCall.args.at(1);
275-
if ('giveMeWriteErrors' in cmd) {
276-
await realIterator.next().catch(() => null); // dismiss response
277-
yield { parse: () => writeErrorsReply };
278-
} else {
279-
yield (await realIterator.next()).value;
274+
try {
275+
const cmd = commandSpy.lastCall.args.at(1);
276+
if ('giveMeWriteErrors' in cmd) {
277+
await realIterator.next().catch(() => null); // dismiss response
278+
yield { parse: () => writeErrorsReply };
279+
} else {
280+
yield (await realIterator.next()).value;
281+
}
282+
} finally {
283+
realIterator.return();
280284
}
281285
});
282286
});

0 commit comments

Comments
 (0)