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

[fix] Wait for process.nextTick if the Request has not drained yet #75

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 18 additions & 16 deletions lib/director/http/index.js
Expand Up @@ -109,24 +109,26 @@ Router.prototype.dispatch = function (req, res, callback) {
} }


if (!stream) { if (!stream) {
// process.nextTick(function () {
// If there is no streaming required on any of the functions on the
// way to `path`, then attempt to parse the fully buffered request stream
// once it has emitted the `end` event.
//
if (req.readable) {
// //
// If the `http.ServerRequest` is still readable, then await // If there is no streaming required on any of the functions on the
// the end event and then continue // way to `path`, then attempt to parse the fully buffered request stream
// once it has emitted the `end` event.
// //
req.once('end', parseAndInvoke) if (req.readable) {
} //
else { // If the `http.ServerRequest` is still readable, then await
// // the end event and then continue
// Otherwise, just parse the body now. //
// req.once('end', parseAndInvoke)
parseAndInvoke(); }
} else {
//
// Otherwise, just parse the body now.
//
parseAndInvoke();
}
});
} }
else { else {
this.invoke(runlist, thisArg, callback); this.invoke(runlist, thisArg, callback);
Expand Down