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: remove `waitTrailers` listener after closing a stream by RidgeA · Pull Request #21764 · nodejs/node

Conversation

@RidgeA

@RidgeA RidgeA commented Jul 11, 2018

Copy link
Copy Markdown
Contributor

When writeHear of Http2ServerResponse instance are called with 204,
205 and 304 status codes an underlying stream closes.
If call end method after sending any of these status codes it will
cause an error TypeError: Cannot read property 'Symbol(trailers)' of undefined because a reference to Http2ServerResponse instance
associated with Http2Stream already was deleted.
The closing of stream causes emitting watiTrailers event and, when
this event handles inside onStreamTrailerReady handler, there is
no reference to Http2ServerResponse instance.

Fises: #21740

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

After applying this changes trailing headers won't be sent if 204/205 and 204 status has been sent.
However, I don't think It is a problem, as according to standard for this HTTP status codes server shouldn't generate payload and have to close a connection after sending the blank line terminating the header section.

204 - https://tools.ietf.org/html/rfc7231#section-6.3.5
205 - https://tools.ietf.org/html/rfc7231#section-6.3.6
304 - https://tools.ietf.org/html/rfc7232#section-4.1

Additional info:
https://tools.ietf.org/html/rfc7230#section-3.3.3 (point 1)
https://tools.ietf.org/html/rfc7540#section-8.1.2.4

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
@RidgeA
http2: remove waitTrailers listener after closing a stream
5222ec2
When `writeHear` of `Http2ServerResponse` instance are called with 204,
205 and 304 status codes an underlying stream closes.
If call `end` method after sending any of these status codes it will
cause an error `TypeError: Cannot read property 'Symbol(trailers)' of
undefined` because a reference to `Http2ServerResponse` instance
associated with Http2Stream already was deleted.
The closing of stream causes emitting `watiTrailers` event and, when
this event handles inside `onStreamTrailerReady`  handler, there is
no reference to Http2ServerResponse instance.

Fises: #21740
@nodejs-github-bot nodejs-github-bot added dont-land-on-v4.x http2 Issues and PRs related to the http2 subsystem. labels Jul 11, 2018
@RidgeA RidgeA mentioned this pull request Jul 11, 2018
HTTP2: Calling res.end after res.writeHead(204) cause an error #21740
Closed
@Trott

Trott commented Jul 11, 2018

Copy link
Copy Markdown
Member

@nodejs/http2

All reactions

Sorry, something went wrong.

Uh oh!

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

jasnell
jasnell approved these changes Jul 11, 2018
View reviewed changes
@mcollina

mcollina commented Jul 12, 2018

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@RidgeA

RidgeA commented Jul 12, 2018

Copy link
Copy Markdown
Contributor Author

Did I break something in FreeBSD?
If It it is my fault - let me know, please.

All reactions

Sorry, something went wrong.

Uh oh!

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

@mcollina

mcollina commented Jul 12, 2018

Copy link
Copy Markdown
Member

Very likely it's a flaky test. I've resumed the build.

All reactions

Sorry, something went wrong.

Uh oh!

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

mcollina
mcollina approved these changes Jul 12, 2018
View reviewed changes

@mcollina mcollina 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

Sorry, something went wrong.

Uh oh!

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

All reactions
BridgeAR
BridgeAR approved these changes Jul 12, 2018
View reviewed changes

@BridgeAR BridgeAR 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. My nits do not have to be addressed but it would still be nice :)

Sorry, something went wrong.

Uh oh!

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

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

this[kProxySocket] = null;

this.off('wantTrailers', onStreamTrailersReady);

@BridgeAR BridgeAR Jul 12, 2018

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.

Nit: would you be so kind and use removeListener instead? That seems much clearer from the semantics and is therefore easier to grasp :-)

Sorry, something went wrong.

Uh oh!

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

All reactions

@RidgeA RidgeA Jul 13, 2018

Copy link
Copy Markdown
Contributor 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.

Done

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread test/parallel/test-http2-compat-serverresponse-end-after-statuses-withou-body.js Outdated
HTTP_STATUS_RESET_CONTENT,
HTTP_STATUS_NOT_MODIFIED,
];
const STATUS_CODES_COUNT = STATUS_WITHOUT_BODY.length;

@BridgeAR BridgeAR Jul 12, 2018

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.

Nit: would you mind changing the STATUS_WITHOUT_BODY name to statusWithoutBody? Since it is an array that is actually manipulated it is not really a constant. And constants in Node.js are normally written as: e.g. kStatusCodesCount.

Sorry, something went wrong.

Uh oh!

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

All reactions

@RidgeA RidgeA Jul 13, 2018

Copy link
Copy Markdown
Contributor 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.

Done.

Sorry, something went wrong.

Uh oh!

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

All reactions
@BridgeAR BridgeAR added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Jul 12, 2018
@Trott

Trott commented Jul 12, 2018

Copy link
Copy Markdown
Member

CI that @mcollina started via Resume Build is all green: https://ci.nodejs.org/job/node-test-pull-request/15834/

All reactions

Sorry, something went wrong.

Uh oh!

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

RidgeA added 2 commits July 13, 2018 09:23
@RidgeA
Merge remote-tracking branch 'upstream/master' into fix/21740_http2_e…
0e914d5
…nd_after_writeHead
@RidgeA
Change to off -> removeListener and variable to lowercase
74389f2
@mcollina

mcollina commented Jul 13, 2018

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

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

apapirovski
apapirovski approved these changes Jul 15, 2018
View reviewed changes
@addaleax

addaleax commented Jul 15, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Landed in 8babbc5 (only fixed up minor typos in the commit message and the test name while landing)

Thanks for the PR! 🎉

Edit: Oh, by the way – this was commit no 23000 in this repo! ✨

RidgeA reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

@addaleax addaleax closed this Jul 15, 2018
addaleax pushed a commit that referenced this pull request Jul 15, 2018
@RidgeA @addaleax
http2: remove waitTrailers listener after closing a stream
8babbc5
When `writeHeader` of `Http2ServerResponse` instance are called with
204, 205 and 304 status codes an underlying stream closes.
If call `end` method after sending any of these status codes it will
cause an error `TypeError: Cannot read property 'Symbol(trailers)' of
undefined` because a reference to `Http2ServerResponse` instance
associated with Http2Stream already was deleted.
The closing of stream causes emitting `waitTrailers` event and, when
this event handles inside `onStreamTrailerReady` handler, there is
no reference to Http2ServerResponse instance.

Fixes: #21740
PR-URL: #21764
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
targos pushed a commit that referenced this pull request Jul 16, 2018
@RidgeA @targos
http2: remove waitTrailers listener after closing a stream
238ef58
When `writeHeader` of `Http2ServerResponse` instance are called with
204, 205 and 304 status codes an underlying stream closes.
If call `end` method after sending any of these status codes it will
cause an error `TypeError: Cannot read property 'Symbol(trailers)' of
undefined` because a reference to `Http2ServerResponse` instance
associated with Http2Stream already was deleted.
The closing of stream causes emitting `waitTrailers` event and, when
this event handles inside `onStreamTrailerReady` handler, there is
no reference to Http2ServerResponse instance.

Fixes: #21740
PR-URL: #21764
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
@targos targos mentioned this pull request Jul 17, 2018
v10.7.0 proposal #21851
Merged
This was referenced Jul 18, 2018
2018-07-18 Version 10.7.0 (Current) @targos beevelop/docker-nodejs#207
Closed
2018-07-18 Version 10.7.0 (Current) @targos beevelop/docker-nodejs#208
Closed
2018-07-18 Version 10.7.0 (Current) @targos beevelop/docker-nodejs#209
Closed
2018-07-18 Version 10.7.0 (Current) @targos beevelop/docker-nodejs#210
Closed
2018-07-18 Version 10.7.0 (Current) @targos beevelop/docker-nodejs#211
Closed
kjin pushed a commit to kjin/node that referenced this pull request Aug 23, 2018
@RidgeA @kjin
http2: remove waitTrailers listener after closing a stream
98e81c0
When `writeHeader` of `Http2ServerResponse` instance are called with
204, 205 and 304 status codes an underlying stream closes.
If call `end` method after sending any of these status codes it will
cause an error `TypeError: Cannot read property 'Symbol(trailers)' of
undefined` because a reference to `Http2ServerResponse` instance
associated with Http2Stream already was deleted.
The closing of stream causes emitting `waitTrailers` event and, when
this event handles inside `onStreamTrailerReady` handler, there is
no reference to Http2ServerResponse instance.

Fixes: nodejs#21740
PR-URL: nodejs#21764
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
kjin pushed a commit to kjin/node that referenced this pull request Sep 25, 2018
@RidgeA @kjin
http2: remove waitTrailers listener after closing a stream
1a15129
When `writeHeader` of `Http2ServerResponse` instance are called with
204, 205 and 304 status codes an underlying stream closes.
If call `end` method after sending any of these status codes it will
cause an error `TypeError: Cannot read property 'Symbol(trailers)' of
undefined` because a reference to `Http2ServerResponse` instance
associated with Http2Stream already was deleted.
The closing of stream causes emitting `waitTrailers` event and, when
this event handles inside `onStreamTrailerReady` handler, there is
no reference to Http2ServerResponse instance.

Fixes: nodejs#21740
PR-URL: nodejs#21764
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
kjin pushed a commit to kjin/node that referenced this pull request Oct 16, 2018
@RidgeA @kjin
http2: remove waitTrailers listener after closing a stream
9a0d117
When `writeHeader` of `Http2ServerResponse` instance are called with
204, 205 and 304 status codes an underlying stream closes.
If call `end` method after sending any of these status codes it will
cause an error `TypeError: Cannot read property 'Symbol(trailers)' of
undefined` because a reference to `Http2ServerResponse` instance
associated with Http2Stream already was deleted.
The closing of stream causes emitting `waitTrailers` event and, when
this event handles inside `onStreamTrailerReady` handler, there is
no reference to Http2ServerResponse instance.

Fixes: nodejs#21740
PR-URL: nodejs#21764
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
BethGriggs pushed a commit that referenced this pull request Oct 17, 2018
@RidgeA @BethGriggs
http2: remove waitTrailers listener after closing a stream
e5175e6
When `writeHeader` of `Http2ServerResponse` instance are called with
204, 205 and 304 status codes an underlying stream closes.
If call `end` method after sending any of these status codes it will
cause an error `TypeError: Cannot read property 'Symbol(trailers)' of
undefined` because a reference to `Http2ServerResponse` instance
associated with Http2Stream already was deleted.
The closing of stream causes emitting `waitTrailers` event and, when
this event handles inside `onStreamTrailerReady` handler, there is
no reference to Http2ServerResponse instance.

Fixes: #21740
Backport-PR-URL: #22850
PR-URL: #21764
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
@BethGriggs BethGriggs mentioned this pull request Oct 30, 2018
v8.13.0 proposal #23974
Merged
@beevelop beevelop mentioned this pull request Nov 20, 2018
2018-11-20 Version 8.13.0 'Carbon' (LTS) @MylesBorins prepared by @BethGriggs beevelop/docker-android-nodejs#250
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@jasnell jasnell jasnell approved these changes
@BridgeAR BridgeAR BridgeAR approved these changes
+1 more reviewer
@apapirovski apapirovski apapirovski approved these changes
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

author ready PRs with CI started, the required approvals, and no outstanding review comments. 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

@RidgeA @Trott @mcollina @addaleax @apapirovski @jasnell @BridgeAR @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.