Skip to content
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

http2: add edge case note to GOAWAY request #42190

Merged
Merged
Show file tree
Hide file tree
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
http2: add edge case to GOAWAY request
  • Loading branch information
RafaelGSS committed Mar 3, 2022
commit 30080e2eaad7fec23b72865eb41ca8495a0b31fc
6 changes: 6 additions & 0 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,12 @@ For HTTP/2 Client `Http2Session` instances only, the `http2session.request()`
creates and returns an `Http2Stream` instance that can be used to send an
HTTP/2 request to the connected server.

When a `ClientHttp2Session` is first created, the socket may not yet be
connected. if `clienthttp2session.request()` is called during this time, the
actual request will be deferred until the socket is ready to go.
If the `session` is closed before the actual request be executed, an
`ERR_HTTP2_GOAWAY_SESSION` is thrown.

This method is only available if `http2session.type` is equal to
`http2.constants.NGHTTP2_SESSION_CLIENT`.

Expand Down
22 changes: 22 additions & 0 deletions test/parallel/test-http2-goaway-delayed-request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
aduh95 marked this conversation as resolved.
Show resolved Hide resolved

const http2 = require('http2');

const server = http2.createServer();

server.listen(0, () => {
const client = http2.connect(`http://localhost:${server.address().port}`);
client.on('close', common.mustCall(() => {
server.close();
}));

// The client.close() is executed before the socket is able to make request
const stream = client.request();
stream.on('error', common.expectsError({ code: 'ERR_HTTP2_GOAWAY_SESSION' }));

setImmediate(() => client.close());
});