Skip to content

Commit 484e720

Browse files
committed
test: deflake test-http2-misbehaving-multiplex
Fixes: #54859
1 parent 9db6327 commit 484e720

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

test/parallel/test-http2-misbehaving-multiplex.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,25 @@ const h2test = require('../common/http2');
1515
const server = h2.createServer();
1616
server.on('stream', common.mustCall((stream) => {
1717
stream.respond();
18-
stream.end('ok');
1918

20-
stream.on('error', common.expectsError({
21-
code: 'ERR_HTTP2_ERROR',
22-
constructor: NghttpError,
23-
message: 'Stream was already closed or invalid'
24-
}));
25-
stream.on('close', common.mustCall());
19+
if (stream.id === 3) {
20+
stream.on('close', () => {
21+
// A second Stream ID 1 frame should fail.
22+
// This will cause an error to occur because the client is
23+
// attempting to reuse an already closed stream. This must
24+
// cause the server session to be torn down.
25+
client.write(id1.data);
26+
// This Stream ID 5 frame will never make it to the server.
27+
client.write(id5.data);
28+
});
29+
stream.end('ok');
30+
} else {
31+
stream.on('error', common.expectsError({
32+
code: 'ERR_HTTP2_ERROR',
33+
constructor: NghttpError,
34+
message: 'Stream was already closed or invalid'
35+
}));
36+
}
2637

2738
// Stream ID 5 should never reach the server
2839
assert.notStrictEqual(stream.id, 5);
@@ -52,16 +63,7 @@ server.listen(0, () => {
5263
// Stream ID 1 frame will make it OK.
5364
client.write(id1.data, () => {
5465
// Stream ID 3 frame will make it OK.
55-
client.write(id3.data, () => {
56-
// A second Stream ID 1 frame should fail.
57-
// This will cause an error to occur because the client is
58-
// attempting to reuse an already closed stream. This must
59-
// cause the server session to be torn down.
60-
client.write(id1.data, () => {
61-
// This Stream ID 5 frame will never make it to the server
62-
client.write(id5.data);
63-
});
64-
});
66+
client.write(id3.data);
6567
});
6668
});
6769
});

0 commit comments

Comments
 (0)