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

Don't return error response when clientError is a pipelined HPE_INVALID_METHOD #4471

Merged
merged 3 commits into from
Mar 13, 2024

Conversation

kanongil
Copy link
Contributor

@kanongil kanongil commented Nov 7, 2023

This PR fixes the specific issue in #4363.

This is done by specialcasing clientError errors with code HPE_INVALID_METHOD that have an active request. Since the active request definitely has a valid method (otherwise it would not have passed through the router), this error originates from request data that is supposed to relate to the next request. As such, it should not respond with an error, but with the normal response. A hook is installed to make the connection close once this has been delivered.

Since the existing test suite only exercises this with err.code === 'HPE_INVALID_METHOD', I have added an extra test to exercise it with err.code === 'HPE_INVALID_CHUNK_SIZE' to keep the code coverage at 100%.

I also made a minor cleanup to request._finalize() and request. _setResponse(). _finalize() seems to somewhat assume that any non-Boom this.response object is a Response, when it can also be a Symbol.

Note that ideally, the current request should add a connection: close header, to indicate that it will close the connection.

Closes #4363. Closes #4364.

@kanongil kanongil added the bug Bug or defect label Nov 7, 2023
@kanongil
Copy link
Contributor Author

kanongil commented Nov 7, 2023

Side issue: The CI doesn't actually test on node 18, even though it is the only fully supported node release!

I don't know why the macOS tests fail. They fine work locally.

@Marsup
Copy link
Contributor

Marsup commented Jan 29, 2024

Is it ok to chain end and destroy on a stream like that? I would expect destroy to be hooked to an event or something.

@kanongil
Copy link
Contributor Author

Right you are @Marsup. I don't know why I wanted the extra destroys… They are gone now.

@Marsup Marsup self-assigned this Mar 13, 2024
@Marsup Marsup added this to the 21.3.5 milestone Mar 13, 2024
@Marsup Marsup merged commit 591258a into hapijs:master Mar 13, 2024
18 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug or defect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server crash: Error: Unknown error
2 participants