Skip to content

test: deflake test-http2-misbehaving-multiplex #54872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions test/parallel/test-http2-misbehaving-multiplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,30 @@ const h2 = require('http2');
const net = require('net');
const { NghttpError } = require('internal/http2/util');
const h2test = require('../common/http2');
let client;

const server = h2.createServer();
server.on('stream', common.mustCall((stream) => {
stream.respond();
stream.end('ok');

stream.on('error', common.expectsError({
code: 'ERR_HTTP2_ERROR',
constructor: NghttpError,
message: 'Stream was already closed or invalid'
}));
stream.on('close', common.mustCall());
if (stream.id === 3) {
stream.on('close', () => {
// A second Stream ID 1 frame should fail.
// This will cause an error to occur because the client is
// attempting to reuse an already closed stream. This must
// cause the server session to be torn down.
client.write(id1.data);
// This Stream ID 5 frame will never make it to the server.
client.write(id5.data);
});
stream.end('ok');
} else {
stream.on('error', common.expectsError({
code: 'ERR_HTTP2_ERROR',
constructor: NghttpError,
message: 'Stream was already closed or invalid'
}));
}

// Stream ID 5 should never reach the server
assert.notStrictEqual(stream.id, 5);
Expand All @@ -45,23 +57,14 @@ const id3 = new h2test.HeadersFrame(3, h2test.kFakeRequestHeaders, 0, true);
const id5 = new h2test.HeadersFrame(5, h2test.kFakeRequestHeaders, 0, true);

server.listen(0, () => {
const client = net.connect(server.address().port, () => {
client = net.connect(server.address().port, () => {
client.write(h2test.kClientMagic, () => {
client.write(settings.data, () => {
client.write(settingsAck.data);
// Stream ID 1 frame will make it OK.
client.write(id1.data, () => {
// Stream ID 3 frame will make it OK.
client.write(id3.data, () => {
// A second Stream ID 1 frame should fail.
// This will cause an error to occur because the client is
// attempting to reuse an already closed stream. This must
// cause the server session to be torn down.
client.write(id1.data, () => {
// This Stream ID 5 frame will never make it to the server
client.write(id5.data);
});
});
client.write(id3.data);
});
});
});
Expand Down
Loading