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: fix closedCode NaN, increase test coverage #15154

Conversation

apapirovski
Copy link
Member

@apapirovski apapirovski commented Sep 3, 2017

[kFinish](code) can be triggered without passing code. Until now, the method tried to set closedCode to undefined resulting in NaN closedCode instead of NGHTTP2_NO_ERROR. Added a check for code !== undefined before setting.

Also adds tests for closed (request only, response covered by another PR previously) and closedCode (both).

Adds tests for Http2ServerRequest and Http2ServerResponse setTimeout. Edit: separate PR now: #15156

Let me know if there's anything I can change. Thanks!

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

http2, test

@nodejs-github-bot nodejs-github-bot added the http2 Issues or PRs related to the http2 subsystem. label Sep 3, 2017
@TimothyGu
Copy link
Member

Can you move the setTimeout tests to a different PR?

The actual code part looks sane. Would you mind explaining when kClosed may be called without a code?

@TimothyGu
Copy link
Member

(kFinish, sorry)

@apapirovski apapirovski force-pushed the patch-http2-compat-closed-code-and-test-coverage branch from e2dd893 to e6d33c3 Compare September 3, 2017 00:47
@apapirovski
Copy link
Member Author

apapirovski commented Sep 3, 2017

Took out setTimeout. Will open a PR for it shortly.

Re: when it can be called, pretty much anytime you do response.end() since that emits finish event which will trigger kFinish. The code is only set from _destroy which is called anytime an error happens on the stream (or when one calls it explicitly).

The test included in this will fail if you try it without applying the patch.

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

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

Would be awesome to have that explanation in the commit message!

@apapirovski apapirovski force-pushed the patch-http2-compat-closed-code-and-test-coverage branch from e6d33c3 to 27c9bfe Compare September 3, 2017 01:18
Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

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

Thanks for doing all these! Changes lgtm

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

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

Reaffirming my LGTM...

@targos
Copy link
Member

targos commented Sep 4, 2017

@apapirovski can you please rebase? I'll trigger a CI run then.

[kFinish](code) can be triggered from a 'finish' event (for example
when calling response.end) which does not pass code. That tries to
set closedCode to undefined resulting in NaN closedCode instead of
NGHTTP2_NO_ERROR. Check for code !== undefined before setting.
Adds tests for closed and closedCode.
@apapirovski apapirovski force-pushed the patch-http2-compat-closed-code-and-test-coverage branch from 27c9bfe to 804fdbe Compare September 4, 2017 12:34
@apapirovski
Copy link
Member Author

@targos All good to go now.

@targos
Copy link
Member

targos commented Sep 4, 2017

jasnell pushed a commit that referenced this pull request Sep 7, 2017
[kFinish](code) can be triggered from a 'finish' event (for example
when calling response.end) which does not pass code. That tries to
set closedCode to undefined resulting in NaN closedCode instead of
NGHTTP2_NO_ERROR. Check for code !== undefined before setting.
Adds tests for closed and closedCode.

PR-URL: #15154
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@jasnell
Copy link
Member

jasnell commented Sep 7, 2017

Landed in 800c32d

@jasnell jasnell closed this Sep 7, 2017
MylesBorins pushed a commit that referenced this pull request Sep 10, 2017
[kFinish](code) can be triggered from a 'finish' event (for example
when calling response.end) which does not pass code. That tries to
set closedCode to undefined resulting in NaN closedCode instead of
NGHTTP2_NO_ERROR. Check for code !== undefined before setting.
Adds tests for closed and closedCode.

PR-URL: #15154
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Sep 10, 2017
MylesBorins pushed a commit that referenced this pull request Sep 11, 2017
[kFinish](code) can be triggered from a 'finish' event (for example
when calling response.end) which does not pass code. That tries to
set closedCode to undefined resulting in NaN closedCode instead of
NGHTTP2_NO_ERROR. Check for code !== undefined before setting.
Adds tests for closed and closedCode.

PR-URL: #15154
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 12, 2017
[kFinish](code) can be triggered from a 'finish' event (for example
when calling response.end) which does not pass code. That tries to
set closedCode to undefined resulting in NaN closedCode instead of
NGHTTP2_NO_ERROR. Check for code !== undefined before setting.
Adds tests for closed and closedCode.

PR-URL: #15154
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit to addaleax/node that referenced this pull request Sep 13, 2017
[kFinish](code) can be triggered from a 'finish' event (for example
when calling response.end) which does not pass code. That tries to
set closedCode to undefined resulting in NaN closedCode instead of
NGHTTP2_NO_ERROR. Check for code !== undefined before setting.
Adds tests for closed and closedCode.

PR-URL: nodejs#15154
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
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.

8 participants