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: align OutgoingMessage and ClientRequest destroy #32148

Closed
wants to merge 9 commits into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Mar 8, 2020

Added .destroyed property to OutgoingMessage and ClientRequest
to align with streams.

Fixed ClientRequest.destroy to dump res and re-use socket in agent
pool aligning it with abort.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Added .destroyed property to OutgoingMessage and ClientRequest
to align with streams.

Fixed ClientRequest.destroy to dump res and re-use socket in agent
pool aligning it with abort.
@ronag ronag added http Issues or PRs related to the http subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. labels Mar 8, 2020
@ronag ronag requested review from mcollina and jasnell March 8, 2020 11:42
}

if (!this.aborted && !err) {
err = connResetException('socket hang up');
Copy link
Member Author

Choose a reason for hiding this comment

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

Note, destroy() will emit ECONNRESET while abort won't.

@nodejs-github-bot
Copy link
Collaborator

@ronag

This comment has been minimized.

@ronag
Copy link
Member Author

ronag commented Mar 8, 2020

After this we might want to consider deprecating abort.

@ronag ronag force-pushed the http-client-destroy4 branch 2 times, most recently from b795096 to 36a003a Compare March 8, 2020 12:08
@ronag ronag force-pushed the http-client-destroy4 branch from 36a003a to 54de489 Compare March 8, 2020 12:08
@szmarczak
Copy link
Member

There are some changes needed to be made, but I'm not at home atm, will comment in an hour.

lib/internal/streams/destroy.js Outdated Show resolved Hide resolved
lib/_http_client.js Outdated Show resolved Hide resolved
@ronag
Copy link
Member Author

ronag commented Mar 8, 2020

Removed the risky change with destroyer.

@ronag ronag force-pushed the http-client-destroy4 branch from dae0286 to 88ce624 Compare March 8, 2020 14:01
@ronag
Copy link
Member Author

ronag commented Mar 8, 2020

@nodejs/web-server-frameworks

@ronag ronag force-pushed the http-client-destroy4 branch 2 times, most recently from 844adca to 97bfd14 Compare March 8, 2020 14:21
@ronag ronag force-pushed the http-client-destroy4 branch from 97bfd14 to 0998e9b Compare March 8, 2020 14:21
lib/_http_outgoing.js Show resolved Hide resolved
lib/_http_client.js Outdated Show resolved Hide resolved
lib/_http_client.js Outdated Show resolved Hide resolved
@ronag ronag force-pushed the http-client-destroy4 branch from 92207e2 to 0245e4e Compare March 8, 2020 15:56
@ronag ronag force-pushed the http-client-destroy4 branch from a5199da to 6f11b24 Compare March 8, 2020 16:59
lib/_http_client.js Outdated Show resolved Hide resolved
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@szmarczak szmarczak left a comment

Choose a reason for hiding this comment

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

Looks good! Awesome :D

@szmarczak
Copy link
Member

szmarczak commented Mar 8, 2020

I think it's a good idea to replace

node/lib/_http_incoming.js

Lines 118 to 124 in 7bb4f95

// It's possible that the socket will be destroyed, and removed from
// any messages, before ever calling this. In that case, just skip
// it, since something else is destroying this connection anyway.
IncomingMessage.prototype.destroy = function destroy(error) {
if (this.socket)
this.socket.destroy(error);
};

with

IncomingMessage.prototype.destroy = function destroy(error) {
  if (this.req)
    this.req.destroy(error);
};

@ronag
Copy link
Member Author

ronag commented Mar 8, 2020

@szmarczak See #32153 for that.

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@4d93e10). Click here to learn what that means.
The diff coverage is 94.11%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #32148   +/-   ##
=========================================
  Coverage          ?   97.04%           
=========================================
  Files             ?      197           
  Lines             ?    65027           
  Branches          ?        0           
=========================================
  Hits              ?    63108           
  Misses            ?     1919           
  Partials          ?        0
Impacted Files Coverage Δ
lib/wasi.js 98.49% <94.11%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d93e10...f24b4a7. Read the comment docs.

@ronag
Copy link
Member Author

ronag commented Mar 9, 2020

@ronag ronag added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 10, 2020
@ronag
Copy link
Member Author

ronag commented Mar 10, 2020

@nodejs/http

@ronag
Copy link
Member Author

ronag commented Mar 10, 2020

@nodejs/tsc

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

ronag added a commit that referenced this pull request Mar 10, 2020
Added .destroyed property to OutgoingMessage and ClientRequest
to align with streams.

Fixed ClientRequest.destroy to dump res and re-use socket in agent
pool aligning it with abort.

PR-URL: #32148
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@ronag
Copy link
Member Author

ronag commented Mar 10, 2020

Landed in 173d044

@ronag ronag closed this Mar 10, 2020
@szmarczak
Copy link
Member

Will this be backported to v13.x?

@ronag
Copy link
Member Author

ronag commented Mar 10, 2020

@szmarczak Not as it is right now, it's been labeled semver-major.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. http Issues or PRs related to the http subsystem. 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.

6 participants