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: do no throw in writeHead if state.closed #27682

Closed

Conversation

mcollina
Copy link
Member

The http1 implementation does not throw if the connection is down.
The http2 compat implementation should do the same.

See: fastify/fastify-http-proxy#51.

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

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot nodejs-github-bot added the http2 Issues or PRs related to the http2 subsystem. label May 13, 2019
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

The code change is LGTM. Should we not change the behavior in http to throw an error as well instead? Writing while already closed seems wrong?

@mcollina
Copy link
Member Author

Should we not change the behavior in http to throw an error as well instead? Writing while already closed seems wrong?

That would break a significant number of applications unfortunately. Most applications and frameworks relies on the fact that calling writeHead() is safe.

The http1 implementation does not throw if the connection is down.
The http2 compat implementation should do the same.

See: fastify/fastify-http-proxy#51.
See: fastify/fastify#1494.
@mcollina mcollina force-pushed the http2-compat-state-closed-crash branch from 003cef5 to 04c715f Compare May 17, 2019 13:43
@mcollina
Copy link
Member Author

1 similar comment
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 17, 2019
@mcollina
Copy link
Member Author

Landed in a49ab0f

@mcollina mcollina closed this May 18, 2019
@mcollina mcollina deleted the http2-compat-state-closed-crash branch May 18, 2019 16:31
mcollina added a commit that referenced this pull request May 18, 2019
The http1 implementation does not throw if the connection is down.
The http2 compat implementation should do the same.

See: fastify/fastify-http-proxy#51.
See: fastify/fastify#1494.

PR-URL: #27682
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos pushed a commit that referenced this pull request May 20, 2019
The http1 implementation does not throw if the connection is down.
The http2 compat implementation should do the same.

See: fastify/fastify-http-proxy#51.
See: fastify/fastify#1494.

PR-URL: #27682
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@BridgeAR BridgeAR mentioned this pull request May 21, 2019
4 tasks
@mokimo
Copy link

mokimo commented Nov 13, 2019

I think it's still not completely fixed, getting the issue a bit later here:
https://github.com/nodejs/node/blob/master/lib/internal/http2/compat.js#L637

It does not throw when using http1, but does when using http2 compat implemenation

@mcollina
Copy link
Member Author

@mokimo would you mind opening a new issue with instructions on how to reproduce? (ideally a server + client that calls it).

@mokimo
Copy link

mokimo commented Nov 15, 2019

If I can get a simple example running that'd be perfect... Been unsuccessful so far but will give you a quick ping you once I got something hands-on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants