Skip to content

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

Closed
mcollina wants to merge 1 commit into
nodejs:masterfrom
mcollina:double-destroy-callback
Closed

stream: fix destroy(err, cb) regression#13156
mcollina wants to merge 1 commit into
nodejs:masterfrom
mcollina:double-destroy-callback

Conversation

@mcollina
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the missing semicolon pass make lint?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

@mcollina mcollina force-pushed the double-destroy-callback branch 2 times, most recently from 1f399e1 to 502bfaf Compare May 22, 2017 16:11
@mcollina
Copy link
Copy Markdown
Member Author

Copy link
Copy Markdown
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@mcollina mcollina force-pushed the double-destroy-callback branch from 502bfaf to c294477 Compare May 22, 2017 16:19
@mcollina
Copy link
Copy Markdown
Member Author

cc @lpinca

@mcollina
Copy link
Copy Markdown
Member Author

CI (without linting errors): https://ci.nodejs.org/job/node-test-pull-request/8232/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 double-destroy-callback branch from c294477 to f4813b1 Compare May 22, 2017 16:48
@mcollina mcollina added v8.x net Issues and PRs related to the net subsystem. stream Issues and PRs related to the stream subsystem. and removed v8.x labels May 22, 2017
@mcollina mcollina added this to the 8.0.0 milestone May 22, 2017
Copy link
Copy Markdown
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

Some questions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

@mcollina mcollina May 22, 2017

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"

Comment thread lib/internal/streams/destroy.js Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.