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: [compat api] allow 'aborted' event on Http2ServerResponse instances and trigger those on session.socket's 'sessionError' #32937

Closed
wants to merge 13 commits into from

Conversation

rexagod
Copy link
Member

@rexagod rexagod commented Apr 20, 2020

EDIT: Removed Fixes: #28267 in accordance to #32937 (review)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the http2 Issues or PRs related to the http2 subsystem. label Apr 20, 2020
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @nodejs/tsc

doc/api/http2.md Outdated Show resolved Hide resolved
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @nodejs/tsc

doc/api/http2.md Outdated Show resolved Hide resolved
test/parallel/test-http2-client-destroy.js Outdated Show resolved Hide resolved
lib/internal/http2/core.js Outdated Show resolved Hide resolved
@mcollina mcollina requested a review from a team April 22, 2020 19:25
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina
Copy link
Member

@nodejs/http2 @nodejs/tsc PTAL

doc/api/http2.md Outdated Show resolved Hide resolved
@mcollina
Copy link
Member

cc @jasnell

@ronag
Copy link
Member

ronag commented Apr 22, 2020

I think the idea of #28267 was that 'aborted' should be emitted on the http2 compat response object, not the server.

rexagod added 2 commits April 23, 2020 04:20
emit `aborted` on `Http2ServerRequest` instance,
added docs and tests, and removed older changes
@rexagod rexagod changed the title http2: emit 'aborted' events instead of 'sessionError' http2: emit aborted on Http2ServerRequest instances Apr 23, 2020
@rexagod rexagod changed the title http2: emit aborted on Http2ServerRequest instances http2: [compat api] emit aborted on Http2ServerRequest instances Apr 23, 2020
@rexagod
Copy link
Member Author

rexagod commented Apr 28, 2020

@ronag @mcollina I've reverted old changes and made some new ones. Please review.

@ronag
Copy link
Member

ronag commented Apr 28, 2020

Can you add a test that checks that if you get a sessionError with ECONNRESET that also means you get an aborted on the outgoing object?

@rexagod rexagod changed the title http2: [compat api] emit aborted on Http2ServerRequest instances http2: [compat api] allow 'aborted' event on Http2ServerResponse instances and trigger it on 'sessionError' Apr 29, 2020
@rexagod rexagod changed the title http2: [compat api] allow 'aborted' event on Http2ServerResponse instances and trigger it on 'sessionError' http2: [compat api] allow 'aborted' event on Http2ServerResponse instances and trigger those on session.socket's 'sessionError' Apr 29, 2020
@rexagod
Copy link
Member Author

rexagod commented Apr 29, 2020

@ronag How did you invoke the socketOnError method? I'm unable to reproduce an ECONNRESET error. I tried to explicitly emit error events on ClientHttp2Session.sockets but since sockets aren't allowed to be manipulated, I get an ERR_HTTP2_NO_SOCKET_MANIPULATION error, not the ECONNRESET one. 😕

@BridgeAR
Copy link
Member

@ronag PTAL

@BridgeAR BridgeAR requested a review from ronag May 28, 2020 00:00
@ronag
Copy link
Member

ronag commented May 28, 2020

@ronag How did you invoke the socketOnError method?

I don't remember. Was a long time ago. I probably got it in production somewhere.

doc/api/http2.md Outdated Show resolved Hide resolved
Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is how HTTP/1 behaves. Please see comment and confirm. If that's not how HTTP/1 behaves it might make sense to make it so as part of a semver-major.

Also, this doesn't actually solve #28267 so we should probably remove the reference.

@@ -15,7 +15,7 @@ const server = h2.createServer(common.mustCall(function(req, res) {
req.on('error', common.mustNotCall());
res.on('error', common.mustNotCall());
req.on('aborted', common.mustCall());
res.on('aborted', common.mustNotCall());
res.on('aborted', common.mustCall());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you confirm that the corresponding code for HTTP1 would actually emit 'aborted' here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronag ServerResponse did not emit 'aborted' with the following code.

// differences from the HTTP/2 corresponding code
// IncomingMessage: did not emit 'error', emitted only 'aborted' event
// ServerResponse: did not emit neither 'error' nor 'aborted' events
const server = http.createServer(common.mustCall((req, res) => {
  // req.on('error', common.mustCall()) // fails
  // res.on('error', common.mustCall()) // fails
  req.on('aborted', common.mustCall(() => {
    assert.ok(req.aborted); // passes
  }));
  // res.on('aborted', common.mustCall()) // fails
  res.write('xyz');
  server.close();
})).listen(0, common.mustCall(function () {
  const request = http.get({
    path: '/',
    port: server.address().port
  }, function(res) {
    res.on('data', common.mustCall((d) => {
      request.destroy();
    }));
  });
}));

@rexagod
Copy link
Member Author

rexagod commented Jun 8, 2020

Ping @ronag

@ronag
Copy link
Member

ronag commented Jun 14, 2020

Given #32937 (comment). What is this fixing? The way I see it this actually diverges from the http/1 behavior?

@rexagod
Copy link
Member Author

rexagod commented Jun 15, 2020

@ronag Feel free to close this if you think that's the best option here.

However, at this point, I'm interested in the best approach we can take to fix #28267 given its irreproducibility?

@rexagod
Copy link
Member Author

rexagod commented Jun 15, 2020

Nonetheless, I've run into ECONNRESET a few times, just not sure if this was emitted from the same method we're talking about. I'll take another go at this in a separate PR soon.

@rexagod rexagod closed this Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants