Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@oyyd
Copy link
Contributor

@oyyd oyyd commented Oct 6, 2018

When an instance of StreamWrap is shutting down and a "drain" event is emitted, the process will abort as its this[kCurrentShutdownRequest] is already set by doShutdown itself.

The following test will fail before this commit.

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

lib/internal/wrap_js_stream.js Outdated Show resolved Hide resolved
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

The following test will fail before this commit.

Is there a way to reach this error through public API? If so, can we use that for the test?

@@ -114,7 +111,9 @@ class JSStreamWrap extends Socket {

if (this[kCurrentWriteRequest] !== null)
return this.on('drain', () => this.doShutdown(req));
assert.strictEqual(this[kCurrentWriteRequest], null);
Copy link
Member

Choose a reason for hiding this comment

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

This assertion can stay, right? Or is it “too obvious” that it’s true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. We can't be too careful here.

@@ -114,7 +111,9 @@ class JSStreamWrap extends Socket {

if (this[kCurrentWriteRequest] !== null)
return this.on('drain', () => this.doShutdown(req));
Copy link
Member

Choose a reason for hiding this comment

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

Aside: This should be .once(), I think?

@oyyd
Copy link
Contributor Author

oyyd commented Oct 7, 2018

I reached this error when I tried to use StreamWrap to wrap a server-side socket which, IMHO, might be a solution to issues like #10871.

In fact, I can't produce this through public API as doShutdown are always called by functions from stream.Writable instead of onshutdown from JSStream, IDK. This test is an imitation of this one. Therefore, feel free to oppose this PR.

As the situations that would reach this line of code seem to be rare, removing the listener to drain might come into consideration? (I'm not sure)

When an instance of StreamWrap is shutting down and a "drain" event
is emitted, the instance will abort as its
`this[kCurrentShutdownRequest]` is already set. The following test
will fail before this commit.
@oyyd
Copy link
Contributor Author

oyyd commented Oct 7, 2018

The travis ci is green now. I didn't notice the core-validate-commit there.

@addaleax
Copy link
Member

addaleax commented Oct 7, 2018

@addaleax addaleax added tls Issues and PRs related to the tls subsystem. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Oct 7, 2018
@danbev
Copy link
Contributor

danbev commented Oct 12, 2018

Landed in e4dea40.

@danbev danbev closed this Oct 12, 2018
danbev pushed a commit that referenced this pull request Oct 12, 2018
When an instance of StreamWrap is shutting down and a "drain" event
is emitted, the instance will abort as its
`this[kCurrentShutdownRequest]` is already set. The following test
will fail before this commit.

PR-URL: #23294
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Trott pushed a commit that referenced this pull request Oct 13, 2018
When an instance of StreamWrap is shutting down and a "drain" event
is emitted, the instance will abort as its
`this[kCurrentShutdownRequest]` is already set. The following test
will fail before this commit.

PR-URL: #23294
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
targos pushed a commit that referenced this pull request Oct 13, 2018
When an instance of StreamWrap is shutting down and a "drain" event
is emitted, the instance will abort as its
`this[kCurrentShutdownRequest]` is already set. The following test
will fail before this commit.

PR-URL: #23294
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
jasnell pushed a commit that referenced this pull request Oct 17, 2018
When an instance of StreamWrap is shutting down and a "drain" event
is emitted, the instance will abort as its
`this[kCurrentShutdownRequest]` is already set. The following test
will fail before this commit.

PR-URL: #23294
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
MylesBorins pushed a commit that referenced this pull request Oct 30, 2018
When an instance of StreamWrap is shutting down and a "drain" event
is emitted, the instance will abort as its
`this[kCurrentShutdownRequest]` is already set. The following test
will fail before this commit.

PR-URL: #23294
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
@codebytere codebytere mentioned this pull request Nov 27, 2018
rvagg pushed a commit that referenced this pull request Nov 28, 2018
When an instance of StreamWrap is shutting down and a "drain" event
is emitted, the instance will abort as its
`this[kCurrentShutdownRequest]` is already set. The following test
will fail before this commit.

PR-URL: #23294
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
MylesBorins pushed a commit that referenced this pull request Nov 29, 2018
When an instance of StreamWrap is shutting down and a "drain" event
is emitted, the instance will abort as its
`this[kCurrentShutdownRequest]` is already set. The following test
will fail before this commit.

PR-URL: #23294
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
@codebytere codebytere mentioned this pull request Nov 29, 2018
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. tls Issues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.