FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

http: use `autoDestroy: true` in incoming message by dnlup · Pull Request #33035 · nodejs/node · GitHub

/ node Public

http: use autoDestroy: true in incoming message - #33035

Closed
dnlup wants to merge 7 commits into
nodejs:masterfrom
dnlup:_http_incoming_autodestroy
Closed

http: use autoDestroy: true in incoming message#33035
dnlup wants to merge 7 commits into
nodejs:masterfrom
dnlup:_http_incoming_autodestroy

Conversation

dnlup commented Apr 24, 2020
edited
Loading

Copy link
Copy Markdown
Contributor

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 logic
inside of it.

Ref:

#30625

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Apr 24, 2020
dnlup force-pushed the _http_incoming_autodestroy branch from f4960e4 to 95d8354 Compare April 29, 2020 05:14

ronag commented Apr 30, 2020
edited
Loading

Copy link
Copy Markdown
Member

IncomingMessage overrides destroy() which kind of blocks any effort in this regards. That needs to IMO be fixed first.

dnlup commented May 1, 2020

Copy link
Copy Markdown
Contributor Author

IncomingMessage overrides destroy() which kind of blocks any effort in this regards. That needs to IMO be fixed first.

Thanks, @ronag, for the suggestion. I'll look into it. There is an issue with destroy for sure. When using keep-alive, we don't want to destroy the socket, and that's what's happening by just setting the option to true.

dnlup force-pushed the _http_incoming_autodestroy branch from 95d8354 to 28da814 Compare May 4, 2020 08:28

dnlup commented May 6, 2020

Copy link
Copy Markdown
Contributor Author

Sorry if this is taking a long time, but I am trying to figure out what's wrong 🙏

Removing the override of destroy() resolves the EECONRESET errors, fewer tests are failing, but request is emitting close twice, and some connections seem to hang.

dnlup force-pushed the _http_incoming_autodestroy branch 3 times, most recently from 336478c to 62e8aec Compare May 20, 2020 06:36
dnlup marked this pull request as ready for review May 20, 2020 06:36
dnlup force-pushed the _http_incoming_autodestroy branch from 62e8aec to 26a6e60 Compare May 20, 2020 07:09

dnlup commented May 20, 2020
edited
Loading

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

@ronag PTAL

BridgeAR requested a review from ronag May 27, 2020 23:56

ronag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Comment thread lib/_http_incoming.js Outdated

dnlup commented May 28, 2020

Copy link
Copy Markdown
Contributor Author

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 _destroy. I also agree that it is ugly, sorry. I wasn't sure I could change the _http_server.js parts.

Thanks for the pointers.

BridgeAR force-pushed the master branch 2 times, most recently from 8ae28ff to 2935f72 Compare May 31, 2020 12:18

dnlup commented Jun 3, 2020

Copy link
Copy Markdown
Contributor Author

Do we need to keep this behavior? If we do, I think it would be better to implement the destroy logic directly in IncomingMessage and not reusing the general lib/internal/streams/destroy.js implementation as I did. Overriding that implementation causes a lot of tests to fail because they are expecting an unhandled error. Also, do you have anything against adding an abort method on IncomingMessage?

ronag commented Jun 3, 2020

Copy link
Copy Markdown
Member

Do we need to keep this behavior?

Yes, just call destroy and move the logic there?

If we do, I think it would be better to implement the destroy logic directly in IncomingMessage and not reusing the general lib/internal/streams/destroy.js implementation as I did.

I disagree. We should implement it as a regular destroy.

Overriding that implementation causes a lot of tests to fail because they are expecting an unhandled error.

Can still be an unhandeld error?

Also, do you have anything against adding an abort method on IncomingMessage?

Yes, destroy should be abort. We just deprecated abort on ClientRequest in favor of destroy.

dnlup commented Jun 3, 2020

Copy link
Copy Markdown
Contributor Author

Yes, just call destroy and move the logic there?

Ok.

I disagree. We should implement it as a regular destroy.

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.

Yes, destroy should be abort. We just deprecated abort on ClientRequest in favor of destroy.

Got it.

ronag commented Jun 3, 2020

Copy link
Copy Markdown
Member

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.

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.

dnlup force-pushed the _http_incoming_autodestroy branch 4 times, most recently from 872f751 to 3231c42 Compare June 9, 2020 06:23
Comment thread lib/_http_incoming.js Outdated
Comment thread lib/_http_client.js Outdated
Comment thread test/parallel/test-http-aborted.js Outdated
Comment thread lib/_http_incoming.js Outdated

dnlup commented Dec 27, 2020

Copy link
Copy Markdown
Contributor Author

Sorry if it took me a while:

#36647

devinivy mentioned this pull request Feb 2, 2021
1 task

simhnna commented Jul 23, 2026

Copy link
Copy Markdown

Sorry to revive an ancient discussion, but what how did you intend client aborts to be handled after this change? It looks like currently the only way is to listen on close of responses and check if writableFinished is set to false.

I opened #46666 and more or less completely forgot about it 😅, since it didn't get any attention I wrote something myself, but I'm not sure if the current way should just be documented, or if the abort event should be called again. Maybe you can chime in?

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

http Issues or PRs related to the http subsystem. notable-change PRs with changes that should be highlighted in changelogs. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.


Back | FazBrowse Home | New Git URL