Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 26f2eb8

Browse filesBrowse files
antsmartianaddaleax
authored andcommitted
http2: add test case for goaway
PR-URL: #24054 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 2b0c853 commit 26f2eb8
Copy full SHA for 26f2eb8

File tree

Expand file treeCollapse file tree

1 file changed

+27
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+27
-0
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-http2-client-destroy.js
+27Lines changed: 27 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.