-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Server crash: Error: Unknown error #4363
Comments
Thanks for the report. I have investigated the issue, and have an understanding on what is going on. The crash itself happens when Hapi encounters an inconsistent internal state here, where Line 566 in b8ba0ad
Now, how does Hapi get into this inconsistent state? This happens because your crafted request initially looks OK, and Hapi starts the regular request processing chain. However, before this processing is completed, the connection emits an Lines 553 to 557 in b8ba0ad
This logic sends an immediate custom response, but is not designed to work while the regular request processing is active! This means that the regular request processing will continue to run, and eventually crash the server once it tries to set a new response. The fix will probably be to stop or limit the regular request processing once the |
A bit further analysis show that the error is isolated to lifecycle handlers that return any response, during which a The fix will be to add another if (this._isReplied) {
return;
} after Lines 370 to 376 in b8ba0ad
since the state can change during the |
I don't have time to create a PR with a failing testcase, so hope someone else can finish this. |
I tried to use server.inject to reproduce this, but was unable to - any tips how this can be done? |
Yeah, You will need to Lines 564 to 567 in b8ba0ad
|
I will try to make a Pull Request. |
I have fixed the issue, but having trouble getting coverage for |
@kanongil Do you have any suggestion what to do here to get the coverage up? |
Had another look into this, and it seems that my analysis was slightly wrong. Node errors with Hapi seems gets a This fix means that this case won't fail anymore, but return a code |
Support plan
Context
What are you trying to achieve or the steps to reproduce?
So playing with some invalid headers, I found a bug.
Test case hapi server
command to reproduce the crash:
nc 127.0.0.1 8080 < body.txt
body.txt
What was the result you got?
Inspecting the request.response surfaces this stack:
So my assumption is that the there is some missing cleanup while handling the actual error response.
What result did you expect?
Server should not die.
The text was updated successfully, but these errors were encountered: