diff --git a/lib/http.js b/lib/http.js index 5013f3c0a3..d8a22bb0bb 100644 --- a/lib/http.js +++ b/lib/http.js @@ -160,7 +160,9 @@ function parserOnMessageComplete() { stream._readableState.onread(null, null); } - if (!stream._readableState.endEmitted && !parser.incoming._pendings.length) { + if (stream && + !stream._readableState.endEmitted && + !parser.incoming._pendings.length) { // For emit end event stream._readableState.onread(null, null); }