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

stream: fix destroy(err, cb) regression #13156

Closed
wants to merge 1 commit into from

Conversation

@mcollina
Copy link
Member

commented May 22, 2017

Fixed a regression that caused the callback passed to destroy()
to not be called if the stream was already destroyed.
This caused a regression on the ws module in CITGM, as discovered
by @refack.

Fixes: websockets/ws#1118

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

stream, net

@mcollina mcollina requested review from refack, calvinmetcalf and cjihrig May 22, 2017

test/parallel/test-stream-writable-destroy.js Outdated

write.destroy();

const expected = new Error('kaboom')

This comment has been minimized.

Copy link
@cjihrig

cjihrig May 22, 2017

Contributor

Does the missing semicolon pass make lint?

This comment has been minimized.

Copy link
@mcollina

mcollina May 22, 2017

Author Member

nope, I have some leftover files with linting errors under bench, and I didn't spot those :(. Updated

@mcollina mcollina force-pushed the mcollina:double-destroy-callback branch 2 times, most recently May 22, 2017

@cjihrig
Copy link
Contributor

left a comment

LGTM

test/parallel/test-net-socket-destroy-send.js Outdated

conn.on('connect', common.mustCall(function() {
conn.destroy();
conn.on('error', common.mustCall());

This comment has been minimized.

Copy link
@cjihrig

cjihrig May 22, 2017

Contributor

It might be worth doing some assertion on the error received here.

@mcollina mcollina force-pushed the mcollina:double-destroy-callback branch May 22, 2017

@mcollina

This comment has been minimized.

Copy link
Member Author

commented May 22, 2017

cc @lpinca

@mcollina

This comment has been minimized.

Copy link
Member Author

commented May 22, 2017

test/parallel/test-stream-readable-destroy.js Outdated

const expected = new Error('kaboom');

// the callback will be called asynchronously

This comment has been minimized.

Copy link
@refack

refack May 22, 2017

Member

If this statement is important you should assert it (set a field on expected on line 177 and assert it's there in line 175).

@mcollina mcollina force-pushed the mcollina:double-destroy-callback branch May 22, 2017

@mcollina mcollina added v8.x net stream and removed v8.x labels May 22, 2017

@mcollina mcollina added this to the 8.0.0 milestone May 22, 2017

@refack
Copy link
Member

left a comment

Some questions.

const assert = require('assert');

const server = net.createServer();
server.listen(0, common.mustCall(function() {

This comment has been minimized.

Copy link
@refack

refack May 22, 2017

Member

Personally I like it that if a function is used it's a strong indicator that you need this bound.

This comment has been minimized.

Copy link
@mcollina

mcollina May 22, 2017

Author Member

This is just a plain old ES5 function. I tend to say the contrary: I use () => {} as a strong indicator that I need this to stay the same.

This comment has been minimized.

Copy link
@refack

refack May 22, 2017

Member

Cool.

test/parallel/test-stream-writable-destroy.js Outdated

const expected = new Error('kaboom');

// the callback will be called asynchronously

This comment has been minimized.

Copy link
@refack
@@ -8,7 +8,10 @@ function destroy(err, cb) {
this._writableState.destroyed;

This comment has been minimized.

Copy link
@refack

refack May 22, 2017

Member

IMHO If the cb should stay undocumented don't put it in the signature, extract it from arguments.
My IDE (WebStorm) will intellisense it's presence.

This comment has been minimized.

Copy link
@cjihrig

cjihrig May 22, 2017

Contributor

IMHO we shouldn't use arguments ever unless we really need to.

This comment has been minimized.

Copy link
@mcollina

mcollina May 22, 2017

Author Member

this was done in the previous PR, I would prefer to discuss that in another issue, if you want to fire a PR (I would like to get this in ASAP, keeping it only on the regression).

This comment has been minimized.

Copy link
@refack

refack May 22, 2017

Member

Not feeling strongly about this... Just FYI.

@refack

This comment has been minimized.

Copy link
Member

commented May 22, 2017

P.S. take the @ off my name in the commit comment (or remove the attribution, I don't mind), I get pinged every time you push 😄

stream: fix destroy(err, cb) regression
Fixed a regression that caused the callback passed to destroy()
to not be called if the stream was already destroyed.
This caused a regression on the ws module in CITGM introduced by
#12925.

Fixes: websockets/ws#1118

@mcollina mcollina force-pushed the mcollina:double-destroy-callback branch to 17aebdf May 22, 2017

@refack

This comment has been minimized.

Copy link
Member

commented May 22, 2017

[question] About synchronicity of the call to cb, is there a convention?

@mcollina

This comment has been minimized.

Copy link
Member Author

commented May 22, 2017

@refack there is not. In fact, the comment was just wrong and taken from the other place I copied those examples from. That callback should be called synchronously.

@refack
refack approved these changes May 22, 2017
@mcollina

This comment has been minimized.

Copy link
Member Author

commented May 22, 2017

@refack can you confirm this fix does not causes any more regressions, but it fixes the one I introduced?

@refack

This comment has been minimized.

Copy link
Member

commented May 22, 2017

@refack can you confirm this fix does not causes any more regressions, but it fixes the one I introduced?

Waiting to the CITGM to do it's dance.

@refack
refack approved these changes May 22, 2017
Copy link
Member

left a comment

CITGM clean

@lpinca
lpinca approved these changes May 22, 2017
@mcollina

This comment has been minimized.

Copy link
Member Author

commented May 22, 2017

@jasnell this should be on Node v8 as well, as you plan to land 330c8d7.

This might probably be short-circuited and landed if you want to avoid a couple of CITGM failures.

@mcollina mcollina referenced this pull request May 22, 2017
4 of 4 tasks complete
@mcollina

This comment has been minimized.

Copy link
Member Author

commented May 24, 2017

Landed as ccd3ead

@mcollina mcollina closed this May 24, 2017

@mcollina mcollina deleted the mcollina:double-destroy-callback branch May 24, 2017

mcollina added a commit that referenced this pull request May 24, 2017
stream: fix destroy(err, cb) regression
Fixed a regression that caused the callback passed to destroy()
to not be called if the stream was already destroyed.
This caused a regression on the ws module in CITGM introduced by
#12925.

PR-URL: #13156
Fixes: websockets/ws#1118
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
jasnell added a commit that referenced this pull request May 24, 2017
stream: fix destroy(err, cb) regression
Fixed a regression that caused the callback passed to destroy()
to not be called if the stream was already destroyed.
This caused a regression on the ws module in CITGM introduced by
#12925.

PR-URL: #13156
Fixes: websockets/ws#1118
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
jasnell added a commit that referenced this pull request May 28, 2017
stream: fix destroy(err, cb) regression
Fixed a regression that caused the callback passed to destroy()
to not be called if the stream was already destroyed.
This caused a regression on the ws module in CITGM introduced by
#12925.

PR-URL: #13156
Fixes: websockets/ws#1118
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@jasnell jasnell referenced this pull request May 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.