-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure events always include the body, even for immediate responses
This fixes a bug, where responses that completed immediately (a synchronous handler, such that the response was ended before setImmediate fired for the async event) did not include a body. The issue is that Node intentionally resumes to dump the remaining body from the request when the response is finished, if we haven't made any attempt to read it at all (server.resOnFinish). We still want to fire the events async, so they're independent of the processing pipeline, but we need to synchronously start reading the body to ensure Node never does this. Note that this means we do need to actively grab the stream earlier in handlers, since otherwise it runs through buffering, which may truncate streams that go over length. Async handlers who _must_ receive the full request body need to do so synchronously. If not, they can still get the body, but it'll pass through truncation to maxSize en route. Probably doesn't matter in practice since maxSize will be big enough that'll take some time, but relevant for tiny maxSize in tests.
- Loading branch information
Showing
3 changed files
with
44 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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