Skip to content

Commit 26f2eb8

Browse files
antsmartianaddaleax
authored andcommitted
http2: add test case for goaway
PR-URL: #24054 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 2b0c853 commit 26f2eb8

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/parallel/test-http2-client-destroy.js

+27
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,30 @@ const Countdown = require('../common/countdown');
137137
req.destroy();
138138
}));
139139
}
140+
141+
// test close before connect
142+
{
143+
const server = h2.createServer();
144+
145+
server.on('stream', common.mustNotCall());
146+
server.listen(0, common.mustCall(() => {
147+
const client = h2.connect(`http://localhost:${server.address().port}`);
148+
const socket = client[kSocket];
149+
socket.on('close', common.mustCall(() => {
150+
assert(socket.destroyed);
151+
}));
152+
153+
const req = client.request();
154+
// should throw goaway error
155+
req.on('error', common.expectsError({
156+
code: 'ERR_HTTP2_GOAWAY_SESSION',
157+
type: Error,
158+
message: 'New streams cannot be created after receiving a GOAWAY'
159+
}));
160+
161+
client.close();
162+
req.resume();
163+
req.on('end', common.mustCall());
164+
req.on('close', common.mustCall(() => server.close()));
165+
}));
166+
}

0 commit comments

Comments
 (0)