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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, would there be a behavioral difference if you dropped the if statement and wrote it as
this._readableState.readingMore = this._consuming;
?Also, this could use a comment explaining why it's necessary to fiddle with
this._readableState
and whythis._consuming
should be true when monkey-patchingthis.read.
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I believe it would make a difference.
_consuming
can flip only intotrue
, and can't really go back. This is a hack to detect following scenario:Clearly in this case no one has attempted to read from
req
. Thus_consuming
isfalse
here, and in_http_server.js
the request can be_dump
ed. However, initial version (prior to this patch) of this hack wasn't working as expected, because_stream_readable.js
may call.read()
by itself. Luckily it calls it only frommaybeReadMore
, so we could test it here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, does that mean that in practice
this._readableState.readingMore
can be false whenthis._consuming
is true?A comment in the source explaining all that would definitely be appreciated. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can be
false
._stream_readable.js
flips it on and off.