From b0d469c69c49c9186c1a581a7cebce4c5d398947 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 12 Feb 2020 11:36:59 -0800 Subject: [PATCH] quic: temporary fixup for test Get the test running but there's still an issue to resolve here. Specifically, when close() is called prematurely, the cancel error is not emitted on next tick. --- .../test-quic-quicstream-close-early.js | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-quic-quicstream-close-early.js b/test/parallel/test-quic-quicstream-close-early.js index aaacd75435..bc2ed26dcf 100644 --- a/test/parallel/test-quic-quicstream-close-early.js +++ b/test/parallel/test-quic-quicstream-close-early.js @@ -41,25 +41,29 @@ server.on('session', common.mustCall((session) => { session.on('secure', common.mustCall((servername, alpn, cipher) => { const uni = session.openStream({ halfOpen: true }); - // TODO(@jasnell): There's still a bug in here somewhere. If we - // comment out the following line and close without writing - // anything, the test hangs. - uni.write('hi', common.mustCall()); + uni.write('hi', common.expectsError()); + + // TODO(@jasnell): When close is called, it will cause the write + // handlers to be canceled, which results in the error that + // destroys the stream. Unfortunately there's currently a bug + // that does not emit that error on next tick that still needs + // to be tracked down. Setting the error handler before calling + // close works for now but the error should be emitted on + // next tick. + uni.on('error', common.mustCall(() => { + assert.strictEqual(uni.aborted, true); + })); + + + uni.close(3); uni.on('data', common.mustNotCall()); - - uni.on('end', common.mustCall(() => { - debug('Undirectional, Server-initiated stream %d ended on server', - uni.id); - })); + uni.on('end', common.mustNotCall()); uni.on('close', common.mustCall(() => { debug('Unidirectional, Server-initiated stream %d closed on server', uni.id); })); - uni.on('error', common.mustCall(() => { - assert.strictEqual(uni.aborted, true); - })); debug('Unidirectional, Server-initiated stream %d opened', uni.id); })); @@ -86,18 +90,24 @@ server.on('ready', common.mustCall(() => { const stream = req.openStream(); - stream.write('hello', common.mustCall()); - stream.close(1); - - stream.on('end', common.mustNotCall()); + stream.write('hello', common.expectsError()); + // TODO(@jasnell): When close is called, it will cause the write + // handlers to be canceled, which results in the error that + // destroys the stream. Unfortunately there's currently a bug + // that does not emit that error on next tick that still needs + // to be tracked down. Setting the error handler before calling + // close works for now but the error should be emitted on + // next tick. stream.on('error', common.mustCall(() => { assert.strictEqual(stream.aborted, true); })); + stream.close(1); + + stream.on('end', common.mustNotCall()); + stream.on('close', common.mustCall(() => { - debug('Bidirectional, Client-initiated stream %d closed on client', - stream.id); countdown.dec(); }));