Fix some corner case client errors#3971
Merged
hueniverse merged 3 commits intohapijs:masterfrom Sep 14, 2019
Merged
Conversation
This ensures that any active request tied to the socked is logged correctly
|
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It turns out that the trigger in #3969 does indeed contain a bug. Namely that a request, that is aborted during the request lifecycle, can cause a timeout, and log a 503 response even though nothing was ever sent down the wire.
Further investigation found that this was caused by the stream draining code in the default handler, which never completes if the stream is aborted. This in turn means that the
_lifecycle()call inrequest._execute()never returns, and thus skips the call to_reply()that would clear the timeout timer.The other part of the patch relates to the
clientErrorhandling. Here I found a case where a client can receive a400 Bad Requestresponse, while the server logs it as a regular response.This is because, contrary to the node docs, the
clientErrorevent can be triggered while processing anrequeston the socket, which hapi doesn't expect.I have updated the handler, to send a
400 Bad Requestresponse through any outstanding requests instead of writing it directly to the socket, which seems to fix the issue.