GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http2: refactor error handling by mcollina · Pull Request #14991 · nodejs/node

Conversation

@mcollina

@mcollina mcollina commented Aug 23, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This changes the error handling model of ServerHttp2Stream,
ServerHttp2Request and ServerHttp2Response.
An 'error' emitted on ServerHttp2Stream will not go to
'uncaughtException' anymore, but to the server 'clientError'.
On the stream 'error', ServerHttp2Request will emit 'abort', while
ServerHttp2Response would do nothing

See: #14963

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
Affected core subsystem(s)

http2

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@mcollina
mcollina requested a review from jasnell August 23, 2017 16:35
@nodejs-github-bot nodejs-github-bot added the http2 Issues and PRs related to the http2 subsystem. label Aug 23, 2017
@mcollina

mcollina commented Aug 23, 2017

Copy link
Copy Markdown
Member Author

cc @nodejs/http2 @akc42

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Aug 23, 2017
View reviewed changes
Comment thread lib/internal/http2/compat.js Outdated

@jasnell jasnell Aug 23, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

s/purpusefully/purposefully

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jasnell
jasnell reviewed Aug 23, 2017
View reviewed changes
Comment thread lib/internal/http2/core.js Outdated

@jasnell jasnell Aug 23, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

question: should this be nextTick'd?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@benjamingr benjamingr Aug 23, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think so - or at least I'd expect it to. Do we have a guarantee that it will always be deferred by the time _destroy is called?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina Aug 24, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

there is a nextTick on top, https://github.com/nodejs/node/blob/master/lib/internal/http2/core.js#L1509

_destroy is called synchronously. But the error of the _destroy callback will be emitted asynchronously, see https://github.com/nodejs/node/blob/master/lib/internal/streams/destroy.js#L32-L37.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

benjamingr reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
jasnell
jasnell approved these changes Aug 23, 2017
View reviewed changes

@jasnell jasnell left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM but it may be good to add some detail to the documentation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
benjamingr
benjamingr approved these changes Aug 23, 2017
View reviewed changes

@benjamingr benjamingr left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM with 2 nits - would love docs for the newly exposed Http2Stream and Http2Session

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/http2.js Outdated

@benjamingr benjamingr Aug 23, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm fine with this - but increasing the surface of the API is not trivial - and I'd like to see docs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina Aug 24, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I've added them just for test purpose. I'll require the internals.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/http2/core.js Outdated

@benjamingr benjamingr Aug 23, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think so - or at least I'd expect it to. Do we have a guarantee that it will always be deferred by the time _destroy is called?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@akc42

akc42 commented Aug 24, 2017

Copy link
Copy Markdown

The two use cases I have been battling with is

  1. Client sends a last ditch "release_locks" api call on window unload, but has gone away before that api call completes and calls response.end(). I want to catch that situation and log that it has occurred - not have the server crash. But this is distinctly different from ...

  2. When client requests a static file that doesn't exist. This might be because the file genuinely doesn't exist (and therefore I send a 404), or because the client has tried to open a client side route which I need to respond with index.html. I don't really want to be opening a file just to check that prior to using respondWithFile. From a compat layer point of view, it might be better to hoist the core function on the ServerHttp2Stream to the ServerHttp2Response and have that error on this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina force-pushed the http2-errors branch 2 times, most recently from 22498dd to 4d49f2a Compare August 24, 2017 10:16
@mcollina

mcollina commented Aug 24, 2017

Copy link
Copy Markdown
Member Author

I have moved Http2Stream from emitting 'clientError' to emitting 'streamError', because 'clientError' has a specific semantics on HTTP1, and we cannot provide that semantic with HTTP2.

benjamingr reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Aug 24, 2017

Copy link
Copy Markdown
Member Author

I've added a commit that introduces onError for respondWithFile, that should allow to handle 404 or redirects correctly (cc @akc42).

@jasnell @benjamingr please reaffirm your LGTM. It has changed enough to be worth a fresh review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Aug 24, 2017

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/9824/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Aug 24, 2017

Copy link
Copy Markdown
Member Author

This would be a semver-major change if we were not experimental.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Aug 24, 2017
View reviewed changes

@jasnell jasnell left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I likes it!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Trott pushed a commit to Trott/io.js that referenced this pull request Aug 25, 2017
@mcollina @jasnell
http2: refactor error handling
4ca8ff2
This changes the error handling model of ServerHttp2Stream,
ServerHttp2Request and ServerHttp2Response.
An 'error' emitted on ServerHttp2Stream will not go to
'uncaughtException' anymore, but to the server 'streamError'.
On the stream 'error', ServerHttp2Request will emit 'abort', while
ServerHttp2Response would do nothing

See: nodejs#14963

PR-URL: nodejs#14991
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@jasnell

jasnell commented Aug 25, 2017

Copy link
Copy Markdown
Member

Landed in 4ca8ff2

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell closed this Aug 25, 2017
@Trott

Trott commented Aug 26, 2017

Copy link
Copy Markdown
Member

Sorry to report: This has broken CI.

By all appearances, this should never have landed in this condition. The CI was not green. One of the tests added failed on all Windows variants.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott mentioned this pull request Aug 26, 2017
Revert "http2: refactor error handling" #15047
Closed
1 task done
@Trott

Trott commented Aug 26, 2017

Copy link
Copy Markdown
Member

Windows test failure with this:

https://ci.nodejs.org/job/node-test-binary-windows/10729/RUN_SUBSET=1,VS_VERSION=vcbt2015,label=win10/console

not ok 202 parallel/test-http2-respond-file-404
  ---
  duration_ms: 0.170
  severity: fail
  stack: |-
    (node:4708) ExperimentalWarning: The http2 module is an experimental API.
    assert.js:42
      throw new errors.AssertionError({
      ^
    
    AssertionError [ERR_ASSERTION]: 'ENOENT: no such file or directory, open \'c:\\workspace\\node-test-binary-windows\\RUN_SUBSET\\1\\VS_VERSION\\vcbt2015\\label\\ === 'ENOENT: no such file or directory, open \'./not-a-file\''
        at c:\workspace\node-test-binary-windows\RUN_SUBSET\1\VS_VERSION\vcbt2015\label\win10\test\common\index.js:715:16
        at c:\workspace\node-test-binary-windows\RUN_SUBSET\1\VS_VERSION\vcbt2015\label\win10\test\common\index.js:509:15
        at onError (c:\workspace\node-test-binary-windows\RUN_SUBSET\1\VS_VERSION\vcbt2015\label\win10\test\parallel\test-http2-respond-file-404.js:25:9)
        at ServerHttp2Stream.afterOpen (internal/http2/core.js:1704:7)
        at FSReqWrap.oncomplete (fs.js:135:15)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Aug 26, 2017

Copy link
Copy Markdown
Member

Reverted, so reopening so the test can be fixed and this can hopefully be re-landed soon.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott reopened this Aug 26, 2017
mcollina added 2 commits August 27, 2017 14:04
@mcollina
http2: refactor error handling
054c9c6
This changes the error handling model of ServerHttp2Stream,
ServerHttp2Request and ServerHttp2Response.
An 'error' emitted on ServerHttp2Stream will not go to
'uncaughtException' anymore, but to the server 'streamError'.
On the stream 'error', ServerHttp2Request will emit 'abort', while
ServerHttp2Response would do nothing

See: nodejs#14963
@mcollina
http2: respondWith* to the new error handling
2857f15
Fixes: nodejs#14963
@mcollina
mcollina force-pushed the http2-errors branch from 45708fe to 2857f15 Compare August 27, 2017 12:55
@mcollina

mcollina commented Aug 27, 2017

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/9851/

(should be ok this time, please verify)

cc @jasnell

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Aug 27, 2017

Copy link
Copy Markdown
Member Author

Landed as 53c5bf5.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina mcollina closed this Aug 27, 2017
mcollina added a commit that referenced this pull request Aug 27, 2017
@mcollina
http2: refactor error handling
53c5bf5
This changes the error handling model of ServerHttp2Stream,
ServerHttp2Request and ServerHttp2Response.
An 'error' emitted on ServerHttp2Stream will not go to
'uncaughtException' anymore, but to the server 'streamError'.
On the stream 'error', ServerHttp2Request will emit 'abort', while
ServerHttp2Response would do nothing.
It also updates respondWith* to the new error handling.

Fixes: #14963
PR-URL: #14991
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
ghost pushed a commit to ayojs/ayo that referenced this pull request Aug 30, 2017
@mcollina Olivia Hugger
http2: refactor error handling
cdc6217
This changes the error handling model of ServerHttp2Stream,
ServerHttp2Request and ServerHttp2Response.
An 'error' emitted on ServerHttp2Stream will not go to
'uncaughtException' anymore, but to the server 'streamError'.
On the stream 'error', ServerHttp2Request will emit 'abort', while
ServerHttp2Response would do nothing

See: nodejs/node#14963

PR-URL: nodejs/node#14991
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
ghost pushed a commit to ayojs/ayo that referenced this pull request Aug 30, 2017
@mcollina Olivia Hugger
http2: refactor error handling
03d1fc5
This changes the error handling model of ServerHttp2Stream,
ServerHttp2Request and ServerHttp2Response.
An 'error' emitted on ServerHttp2Stream will not go to
'uncaughtException' anymore, but to the server 'streamError'.
On the stream 'error', ServerHttp2Request will emit 'abort', while
ServerHttp2Response would do nothing.
It also updates respondWith* to the new error handling.

Fixes: nodejs/node#14963
PR-URL: nodejs/node#14991
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
ghost pushed a commit to ayojs/ayo that referenced this pull request Aug 30, 2017
@mcollina Olivia Hugger
http2: refactor error handling
167382b
This changes the error handling model of ServerHttp2Stream,
ServerHttp2Request and ServerHttp2Response.
An 'error' emitted on ServerHttp2Stream will not go to
'uncaughtException' anymore, but to the server 'streamError'.
On the stream 'error', ServerHttp2Request will emit 'abort', while
ServerHttp2Response would do nothing

See: nodejs/node#14963

PR-URL: nodejs/node#14991
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
ghost pushed a commit to ayojs/ayo that referenced this pull request Aug 30, 2017
@mcollina Olivia Hugger
http2: refactor error handling
c2b861c
This changes the error handling model of ServerHttp2Stream,
ServerHttp2Request and ServerHttp2Response.
An 'error' emitted on ServerHttp2Stream will not go to
'uncaughtException' anymore, but to the server 'streamError'.
On the stream 'error', ServerHttp2Request will emit 'abort', while
ServerHttp2Response would do nothing.
It also updates respondWith* to the new error handling.

Fixes: nodejs/node#14963
PR-URL: nodejs/node#14991
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@mcollina mcollina mentioned this pull request Sep 1, 2017
test: increase Http2ServerResponse test coverage #15074
Closed
3 tasks done
MylesBorins pushed a commit that referenced this pull request Sep 10, 2017
@mcollina @MylesBorins
http2: refactor error handling
e1b267b
This changes the error handling model of ServerHttp2Stream,
ServerHttp2Request and ServerHttp2Response.
An 'error' emitted on ServerHttp2Stream will not go to
'uncaughtException' anymore, but to the server 'streamError'.
On the stream 'error', ServerHttp2Request will emit 'abort', while
ServerHttp2Response would do nothing.
It also updates respondWith* to the new error handling.

Fixes: #14963
PR-URL: #14991
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Sep 10, 2017
v8.5.0 proposal #15308
Merged
MylesBorins pushed a commit that referenced this pull request Sep 12, 2017
@mcollina @MylesBorins
http2: refactor error handling
989dfaf
This changes the error handling model of ServerHttp2Stream,
ServerHttp2Request and ServerHttp2Response.
An 'error' emitted on ServerHttp2Stream will not go to
'uncaughtException' anymore, but to the server 'streamError'.
On the stream 'error', ServerHttp2Request will emit 'abort', while
ServerHttp2Response would do nothing.
It also updates respondWith* to the new error handling.

Fixes: #14963
PR-URL: #14991
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@mcollina mcollina mentioned this pull request Sep 12, 2017
http2 - compat request forward error #15359
Closed
@MylesBorins MylesBorins added the dont-land-on-v6.x label Sep 20, 2017
@mcollina mcollina mentioned this pull request Mar 8, 2018
http2: fixes error handling #19232
Closed
3 tasks done
mcollina added a commit to mcollina/node that referenced this pull request Mar 8, 2018
@mcollina
http2: fixes error handling
80f9390
There should be no default error handling when using Http2Stream.
All errors will end up in `'streamError'` on the server anyway,
but they are emitted on `'stream'` as well, otherwise some error
conditions are impossible to debug.

See: nodejs#14991
mcollina added a commit that referenced this pull request Mar 12, 2018
@mcollina
http2: fixes error handling
8403f00
There should be no default error handling when using Http2Stream.
All errors will end up in `'streamError'` on the server anyway,
but they are emitted on `'stream'` as well, otherwise some error
conditions are impossible to debug.

See: #14991

PR-URL: #19232
Reviewed-By: James M Snell <[email protected]>
mcollina added a commit to mcollina/node that referenced this pull request Mar 20, 2018
@mcollina
http2: fixes error handling
c2bf08e
There should be no default error handling when using Http2Stream.
All errors will end up in `'streamError'` on the server anyway,
but they are emitted on `'stream'` as well, otherwise some error
conditions are impossible to debug.

See: nodejs#14991

PR-URL: nodejs#19232
Reviewed-By: James M Snell <[email protected]>
@mcollina mcollina mentioned this pull request Mar 20, 2018
[v9.x backport] http2: fixes error handling #19478
Closed
3 of 4 tasks
mcollina added a commit to mcollina/node that referenced this pull request Mar 21, 2018
@mcollina
http2: fixes error handling
f36e5b4
There should be no default error handling when using Http2Stream.
All errors will end up in `'streamError'` on the server anyway,
but they are emitted on `'stream'` as well, otherwise some error
conditions are impossible to debug.

See: nodejs#14991

PR-URL: nodejs#19232
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Mar 21, 2018
@mcollina @MylesBorins
http2: fixes error handling
3914e97
There should be no default error handling when using Http2Stream.
All errors will end up in `'streamError'` on the server anyway,
but they are emitted on `'stream'` as well, otherwise some error
conditions are impossible to debug.

See: #14991

Backport-PR-URL: #19478
PR-URL: #19232
Reviewed-By: James M Snell <[email protected]>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
@mcollina @MayaLekova
http2: fixes error handling
d783243
There should be no default error handling when using Http2Stream.
All errors will end up in `'streamError'` on the server anyway,
but they are emitted on `'stream'` as well, otherwise some error
conditions are impossible to debug.

See: nodejs#14991

PR-URL: nodejs#19232
Reviewed-By: James M Snell <[email protected]>
@pimterry pimterry mentioned this pull request May 11, 2026
Fix HTTP/2 RST_STREAM behaviour, add auto-drain, deprecate 'aborted', fix related compat API issues #63249
Merged
dsb8cwb76c-cmyk
dsb8cwb76c-cmyk reviewed Sep 12, 2026
View reviewed changes

@dsb8cwb76c-cmyk dsb8cwb76c-cmyk left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

You

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@benjamingr benjamingr benjamingr approved these changes
+1 more reviewer
@dsb8cwb76c-cmyk dsb8cwb76c-cmyk dsb8cwb76c-cmyk left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

http2 Issues and PRs related to the http2 subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@mcollina @akc42 @jasnell @Trott @benjamingr @dsb8cwb76c-cmyk @MylesBorins @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.