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

http: remove usage of internal stream state from _http_server #34888

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ function resOnFinish(req, res, socket, state, server) {
// If the user never called req.read(), and didn't pipe() or
// .resume() or .on('data'), then we call req._dump() so that the
// bytes will be pulled off the wire.
if (!req._consuming && !req._readableState.resumeScheduled)
if (!req._consuming && req.paused)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In conflict with #34886

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I tried to use .isPaused() but it looks like the state[kPaused] === true instead of state[kPaused] !== false breaks it. = (

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what exactly is the correct way/property here... I would probably leave this as is :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it doesn't look like it will be easy to change.
The same goes for _http_incoming which uses readingMore = true to basically pause the stream without actually pausing it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronag Just looked at http2 and quic, looks like that is present there as well. Could we think of some sort of public API for that? (I mean readingMore = true etc)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure at the moment why we are doing this but if quic is doing it then it’s probable I will look into it at some point.

req._dump();

res.detachSocket(socket);
Expand Down
16 changes: 16 additions & 0 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,22 @@ ObjectDefineProperties(Readable.prototype, {
}
},

pipesCount: {
enumerable: false,
get() {
return this._readableState ? this._readableState.pipesCount : 0;
}
},

paused: {
enumerable: false,
get() {
return this._readableState ? this._readableState.paused : false;
}
}
});

ObjectDefineProperties(ReadableState.prototype, {
// Legacy getter for `pipesCount`
pipesCount: {
get() {
Expand Down