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

Raise proper Connect error codes for closed streams in handlers #628

Merged
merged 1 commit into from
May 11, 2023

Conversation

timostamm
Copy link
Member

This PR follows up on #531 and adds more test coverage.

We are making sure that we always trigger the AbortSignal in the HandlerContext when a request is finished, and that the abort reason has the proper Connect error code on Node.js.

This includes the mapping of HTTP/2 REST_STREAM codes to Connect error codes, so that requests canceled on the client trigger the signal of the HandlerContext with Code.Canceled.

http2.connect(server.getUrl(), (session: http2.ClientHttp2Session) => {
const stream = session.request(
{
":method": "POST",
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a dumb question, but should we test `GET' requests also now?

Copy link
Member Author

Choose a reason for hiding this comment

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

The server side is not merged yet, cannot add tests for it.

setTimeout(() => {
stream.on("error", () => {
// Closing with _some_ codes raises an ERR_HTTP2_STREAM_ERROR
// error here.
Copy link
Member

Choose a reason for hiding this comment

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

Should this be handled at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

If we don't add this event listener, an error is raised and the tests fail.

@timostamm timostamm merged commit 19a7270 into main May 11, 2023
@timostamm timostamm deleted the tstamm/handler-abort-signal-codes branch May 11, 2023 14:59
@timostamm timostamm mentioned this pull request May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants