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

HTTP/2 request after receiving a "GOAWAY" frame hangs #3140

Closed
kylsgl opened this issue Apr 19, 2024 · 1 comment · Fixed by #3143
Closed

HTTP/2 request after receiving a "GOAWAY" frame hangs #3140

kylsgl opened this issue Apr 19, 2024 · 1 comment · Fixed by #3143
Assignees
Labels
bug Something isn't working

Comments

@kylsgl
Copy link

kylsgl commented Apr 19, 2024

Bug Description

Making a request after getting a 'GOAWAY' frame hangs without returning anything, not even an error. But, request after the hangup works fine.

Reproducible By

const undici = require("undici");

const origin = "https://en.wikipedia.org";

const path = "/wiki/Main_Page";

const agent = new undici.Agent({
  allowH2: true,
});

function makeRequest() {
  agent
    .request({
      origin,
      path,
      method: "GET",
    })
    .then(({ statusCode, body }) => {
      console.log(new Date().toLocaleTimeString(), statusCode);

      return body.text();
    })
    .catch(console.error);
}

makeRequest();

setTimeout(makeRequest, 180_000); // 3 minutes

Expected Behavior

It should re-create the connection or at least throw an error.

Logs & Screenshots

> set NODE_DEBUG=http2&& node index.js

HTTP2 11896: Http2Session client: setting up session handle
HTTP2 11896: Http2Session client: sending settings
HTTP2 11896: Http2Session client: submitting settings
HTTP2 11896: Http2Session client: created
HTTP2 11896: Http2Session client: initiating request
HTTP2 11896: Http2Session client: connected, initializing request
HTTP2 11896: Http2Stream 1 [Http2Session client]: shutting down writable on _final
(node:11896) [UNDICI-H2] Warning: H2 support is experimental, expect them to change at any time.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11896) Warning: Setting the NODE_DEBUG environment variable to 'http2' can expose sensitive data (such as passwords, tokens and authentication headers) in the resulting log.        
HTTP2 11896: Http2Session client: settings received
HTTP2 11896: Http2Stream 1 [Http2Session client]: headers received
HTTP2 11896: Http2Stream 1 [Http2Session client]: emitting stream 'response' event
12:24:18 AM 200
HTTP2 11896: Http2Stream 1 [Http2Session client]: closed with code 0, closed false, readable false
HTTP2 11896: Http2Stream 1 [Http2Session client]: destroying stream
HTTP2 11896: Http2Session client: goaway 0 received [last stream id: 1]
HTTP2 11896: Http2Session client: destroying
HTTP2 11896: Http2Session client: start closing/destroying undefined
HTTP2 11896: Http2Session <invalid>: socket error [HTTP/2: "GOAWAY" frame received with code 0]
HTTP2 11896: Http2Session client: finishSessionClose

Environment

[email protected]
Node v20.12.0

@kylsgl kylsgl added the bug Something isn't working label Apr 19, 2024
@metcoder95
Copy link
Member

metcoder95 commented Apr 21, 2024

Have opened a PR (#3143) to abort requests upon GOAWAY frame, so not it fully reflects the intention of the frame.
Tho, is important to remark that once this frame is received, the sessions get unusable, so still recommended to re-initiate the connection once more after receiving the frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants