-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: use autoDestroy: true
in incoming message
#33035
Conversation
f4960e4
to
95d8354
Compare
|
Thanks, @ronag, for the suggestion. I'll look into it. There is an issue with |
95d8354
to
28da814
Compare
Sorry if this is taking a long time, but I am trying to figure out what's wrong 🙏 Removing the override of |
336478c
to
62e8aec
Compare
62e8aec
to
26a6e60
Compare
The changes made here are overriding the ones you made recently, @ronag . I don't know if this approach is the best. PS: just rebased against master on the last forced push. |
@ronag PTAL |
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.
Please also try to remove all cases of manually managing destroyed
and emitting 'close'
on IncomingMessage
. Having some kind of hybrid solution will make things hard to maintain IMO.
You mean like in here? I agree, that is also the reason why the callback is not called in all cases in Thanks for the pointers. |
8ae28ff
to
2935f72
Compare
Do we need to keep this behavior? If we do, I think it would be better to implement the destroy logic directly in |
Yes, just call destroy and move the logic there?
I disagree. We should implement it as a regular destroy.
Can still be an unhandeld error?
Yes, destroy should be abort. We just deprecated abort on ClientRequest in favor of destroy. |
Ok.
I agree. The only difference I have seen with a regular destroy is that IncomingMessage emits an error only if there are listeners attached, at least when aborting.
Got it. |
I can help with sorting this out. If you have any test that depends on this behavior just comment them out and we can take a look together when that's the only thing remaining. |
872f751
to
3231c42
Compare
Add to the history table that the `destroyed` value returns `true` after the incoming data is consumed. Refs: #36617 Refs: #33035 PR-URL: #36641 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Robert Nagy <[email protected]>
Since 55e83cb has changed the ordering of the close event, add a test case. IncomingMessage will emit close before the response is sent in case the server is consuming data from it. Refs: #33035 (comment) PR-URL: #36645 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
This fixes a major memory leak I encountered usign this on Node v16. Doing a binary search of node versions, the problem appears to originate in v15.5.0 as a result of nodejs/node#33035, however later changes have quietly completely removed the 'aborted' event that `http-proxy` relies on, and later added a deprecation note about it (which seems to actually be incorrect). Despite what the notes about [DEP0156](https://nodejs.org/dist/latest-v16.x/docs/api/deprecations.html#DEP0156) say, the only way I could get this module working reliably again was to replace `req.on('aborted')` with instead checking `res.on('close')` and looking at `res.writeableFinished`.
PR-URL: #42521 Fixes: #38924 Refs: #33035 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: nodejs#42521 Fixes: nodejs#38924 Refs: nodejs#33035 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: #42521 Fixes: #38924 Refs: #33035 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: nodejs#42521 Fixes: nodejs#38924 Refs: nodejs#33035 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: #42521 Fixes: #38924 Refs: #33035 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: #42521 Fixes: #38924 Refs: #33035 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: #42521 Fixes: #38924 Refs: #33035 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: nodejs/node#42521 Fixes: nodejs/node#38924 Refs: nodejs/node#33035 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
This fixes a major memory leak I encountered usign this on Node v16. Doing a binary search of node versions, the problem appears to originate in v15.5.0 as a result of nodejs/node#33035, however later changes have quietly completely removed the 'aborted' event that `http-proxy` relies on, and later added a deprecation note about it (which seems to actually be incorrect). Despite what the notes about [DEP0156](https://nodejs.org/dist/latest-v16.x/docs/api/deprecations.html#DEP0156) say, the only way I could get this module working reliably again was to replace `req.on('aborted')` with instead checking `res.on('close')` and looking at `res.writeableFinished`.
This fixes a major memory leak I encountered usign this on Node v16. Doing a binary search of node versions, the problem appears to originate in v15.5.0 as a result of nodejs/node#33035, however later changes have quietly completely removed the 'aborted' event that `http-proxy` relies on, and later added a deprecation note about it (which seems to actually be incorrect). Despite what the notes about [DEP0156](https://nodejs.org/dist/latest-v16.x/docs/api/deprecations.html#DEP0156) say, the only way I could get this module working reliably again was to replace `req.on('aborted')` with instead checking `res.on('close')` and looking at `res.writeableFinished`. The original commit is [here](http-party@058182a) by Jimbly.
This fixes a major memory leak I encountered usign this on Node v16. Doing a binary search of node versions, the problem appears to originate in v15.5.0 as a result of nodejs/node#33035, however later changes have quietly completely removed the 'aborted' event that `http-proxy` relies on, and later added a deprecation note about it (which seems to actually be incorrect). Despite what the notes about [DEP0156](https://nodejs.org/dist/latest-v16.x/docs/api/deprecations.html#DEP0156) say, the only way I could get this module working reliably again was to replace `req.on('aborted')` with instead checking `res.on('close')` and looking at `res.writeableFinished`.
Enable the default
autoDestroy: true
option in IncomingMessage.Refactor
_http_client
and_http_server
to remove any manual destroying/closing of IncomingMessage.Refactor IncomingMessage
destroy
method to use the standard implementation of the stream module and move the abort logicinside of it.
Ref:
#30625
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes