Skip to content

Commit c2546eb

Browse files
committed
test: deflake test-http2-misbehaving-multiplex
Fixes: #54859
1 parent 741004a commit c2546eb

1 file changed

Lines changed: 19 additions & 33 deletions

File tree

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

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,27 @@ const h2test = require('../common/http2');
1414
let client;
1515

1616
const server = h2.createServer();
17-
let gotFirstStreamId1;
1817
server.on('stream', common.mustCall((stream) => {
1918
stream.respond();
20-
stream.end('ok');
2119

22-
// Http2Server should be fast enough to respond to and close
23-
// the first streams with ID 1 and ID 3 without errors.
24-
25-
// Test for errors in 'close' event to ensure no errors on some streams.
26-
stream.on('error', () => {});
27-
stream.on('close', (err) => {
28-
if (stream.id === 1) {
29-
if (gotFirstStreamId1) {
30-
// We expect our outgoing frames to fail on Stream ID 1 the second time
31-
// because a stream with ID 1 was already closed before.
32-
common.expectsError({
33-
constructor: NghttpError,
34-
code: 'ERR_HTTP2_ERROR',
35-
message: 'Stream was already closed or invalid'
36-
});
37-
return;
38-
}
39-
gotFirstStreamId1 = true;
40-
}
41-
assert.strictEqual(err, undefined);
42-
});
20+
if (stream.id === 3) {
21+
stream.on('close', () => {
22+
// A second Stream ID 1 frame should fail.
23+
// This will cause an error to occur because the client is
24+
// attempting to reuse an already closed stream. This must
25+
// cause the server session to be torn down.
26+
client.write(id1.data);
27+
// This Stream ID 5 frame will never make it to the server.
28+
client.write(id5.data);
29+
});
30+
stream.end('ok');
31+
} else {
32+
stream.on('error', common.expectsError({
33+
code: 'ERR_HTTP2_ERROR',
34+
constructor: NghttpError,
35+
message: 'Stream was already closed or invalid'
36+
}));
37+
}
4338

4439
// Stream ID 5 should never reach the server
4540
assert.notStrictEqual(stream.id, 5);
@@ -69,16 +64,7 @@ server.listen(0, () => {
6964
// Stream ID 1 frame will make it OK.
7065
client.write(id1.data, () => {
7166
// Stream ID 3 frame will make it OK.
72-
client.write(id3.data, () => {
73-
// A second Stream ID 1 frame should fail.
74-
// This will cause an error to occur because the client is
75-
// attempting to reuse an already closed stream. This must
76-
// cause the server session to be torn down.
77-
client.write(id1.data, () => {
78-
// This Stream ID 5 frame will never make it to the server
79-
client.write(id5.data);
80-
});
81-
});
67+
client.write(id3.data);
8268
});
8369
});
8470
});

0 commit comments

Comments
 (0)