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: emit 'close' when sockets are not constructed #33818

Closed
wants to merge 2 commits into from

Conversation

rexagod
Copy link
Member

@rexagod rexagod commented Jun 10, 2020

OutgoingMessage#socket is null for such cases at all times.
Hence, we emit a 'close' event, imitating destroyImpl.destroy,
without the socket operations.

Fixes: #33653

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

`OutgoingMessage#socket` is `null` for such cases at all times.
Hence, we emit a 'close' event, imitating `destroyImpl.destroy`,
without the socket operations.

Fixes: nodejs#33653
@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Jun 10, 2020
lib/_http_outgoing.js Outdated Show resolved Hide resolved
Co-authored-by: James M Snell <jasnell@gmail.com>
@rexagod
Copy link
Member Author

rexagod commented Jun 14, 2020

ping @mcollina

@mcollina mcollina requested a review from ronag June 14, 2020 10:16
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.

Are we emitting 'close' if the stream finish normally?

@ronag wdyt?

@@ -296,6 +296,9 @@ OutgoingMessage.prototype.destroy = function destroy(error) {
});
}

if (this instanceof OutgoingMessage) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this if required?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added this to check for instances where no sockets were constructed, as in msg = new OutgoingMessage (similar to the code snippet in the original issue #33653).

@ronag
Copy link
Member

ronag commented Jun 14, 2020

Are we emitting 'close' if the stream finish normally?

We should always emit a close, eventually...

Though I don't think the implementation in this PR is correct. When we do get a socket 'close', should be emitted on socket.'close' this PR breaks that.

Just so that I understand a bit better... the current code assumes that a socket will always was be assigned eventually... in which case is this false? The test is not a good example since it's never actually used like that.

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

I don't think this is correct, se above comment.

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OutgoingMessage doesn't always emit close
5 participants