-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
HTTP/2 streams cancelled with an AbortSignal should close with NGHTTP2_CANCEL instead of NGHTTP2_INTERNAL_ERROR #47321
Comments
I don't see a problem with that, pull request welcome. Please break it up in separate statements though; your diff exceeds the ternary threshold. :-) |
Hello :) I've run into this same issue. If it's alright with you @timostamm I'd like to move forward with the fix you suggested. |
I have not found time to look into it yet, @devm33, please feel free to take it! |
Thanks @timostamm, opened #48573 @bnoordhuis could this fix be eligible for backporting? It looks like it should merge cleanly into at least 18-staging. |
Fixes: #47321 Refs: https://www.rfc-editor.org/rfc/rfc7540#section-7 PR-URL: #48573 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Fixes: #47321 Refs: https://www.rfc-editor.org/rfc/rfc7540#section-7 PR-URL: #48573 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Fixes: nodejs#47321 Refs: https://www.rfc-editor.org/rfc/rfc7540#section-7 PR-URL: nodejs#48573 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Fixes: nodejs#47321 Refs: https://www.rfc-editor.org/rfc/rfc7540#section-7 PR-URL: nodejs#48573 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Fixes: #47321 Refs: https://www.rfc-editor.org/rfc/rfc7540#section-7 PR-URL: #48573 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Fixes: #47321 Refs: https://www.rfc-editor.org/rfc/rfc7540#section-7 PR-URL: #48573 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Fixes: #47321 Refs: https://www.rfc-editor.org/rfc/rfc7540#section-7 PR-URL: #48573 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Version
v18.15.0
Platform
Darwin XXX 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64
Subsystem
http2
What steps will reproduce the bug?
With an AbortSignal, it's possible to somewhat conveniently cancel an HTTP/2 request. The HTTP/2 spec actually defines an error code to be used for RST_STREAM frame in this case (RFC7540, section 7):
But with a request from the Node.js
http2
module, an AbortSignal will cause the stream to be closed with:The behavior can be reproduced with the attached script, which outputs
stream closed with RST_STREAM error code 2
.How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
I would expect an AbortSignal to send code CANCEL (NGHTTP2_CANCEL), and see the output
stream closed with RST_STREAM error code 8
from the attached script.Using an AbortSignal seems like the best choice today to cancel requests (for example in an application that reaches out to a server for autocomplete suggestions). In such a use-case, having streams close with a code that indicates an unexpected internal error causes issues for observability and metrics.
Of course applications can switch to closing streams manually, but it seems reasonable for the
http2
module to use the appropriate HTTP/2 code instead, and let users continue to use the more convenient AbortSignal.I propose to make a minimal change to lib/internal/http2/core.js - basically:
What do you see instead?
Code INTERNAL_ERROR -
stream closed with RST_STREAM error code 2
from the attached script.Additional information
The text was updated successfully, but these errors were encountered: