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: emit .write() end error in next tick #4749

Closed
wants to merge 1 commit into from

Conversation

phillipj
Copy link
Member

Next up in my TODO triaging, this time in _stream_writable.js.

Assuming it should be labelled semver-major as it changes from emitting error synchronously to async.

@silverwind silverwind added the stream Issues and PRs related to the stream subsystem. label Jan 18, 2016
process.nextTick(cb, er);
function writeAfterEndErr(stream, cb) {
const err = new Error('write after end');
process.nextTick(() => stream.emit('error', err));
Copy link
Contributor

Choose a reason for hiding this comment

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

It would probably be better to just call process.nextTick once here and both emit the error and call the callback.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree.

Copy link
Member Author

Choose a reason for hiding this comment

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

It would probably be better to just call process.nextTick once here and both emit the error and call the callback.

Sure thing, agreed it looked strange. Just pushed an update.

@jasnell
Copy link
Member

jasnell commented Jan 19, 2016

Generally LGTM once @evanlucas, @mscdex and CI are happy :-)

@evanlucas evanlucas added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jan 19, 2016
@evanlucas
Copy link
Contributor

Marking as semver-major as it is a behavior change

@Fishrock123
Copy link
Contributor

@nodejs/streams

@phillipj phillipj force-pushed the emit-ws-end-error-nt branch from b732435 to 227c9f5 Compare January 19, 2016 15:51
@phillipj phillipj force-pushed the emit-ws-end-error-nt branch from 227c9f5 to 76f6165 Compare January 19, 2016 15:52
process.nextTick(() => {
stream.emit('error', err);
cb(err);
});
Copy link
Member

Choose a reason for hiding this comment

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

i'm not sure we transform arrow functions yet in the readable-stream builds. @calvinmetcalf probably knows more about this?

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'm not sure we transform arrow functions yet in the readable-stream builds.

I'll happily change it to an ordinary function. Really curious about what kind of transformation you're talking about though?

Copy link
Member

Choose a reason for hiding this comment

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

the readable-stream module is build from the node source using a couple of build methods, https://github.com/nodejs/readable-stream/tree/master/build to get better browser support.

Copy link
Contributor

Choose a reason for hiding this comment

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

we do not support arrow functions at the moment, and it would be tricky to do so in a performant manner, that being said, you could change this code to be,

function writeAfterEnd(stream, cb) {
  const err = new Error('write after end');
  stream.emit('error', err);
  cb(err);
}

and then replace the use of writeAfterEndErr(this, cb) with

 process.nextTick(writeAfterEnd, this, cb);

and this would avoid creating an unnecessary closure

Copy link
Member Author

Choose a reason for hiding this comment

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

the readable-stream module is build from the node source using a couple of build methods, https://github.com/nodejs/readable-stream/tree/master/build to get better browser support.

Neat, that's some nice wizardry.

and then replace the use of writeAfterEndErr(this, cb) with

Thanks @calvinmetcalf, just pushed an update 👍

@chrisdickinson
Copy link
Contributor

I worry about this a little, in that streams can be enormously fussy when it comes to when things happen. A CITGM run with this would ease my mind a bit (especially if CITGM contains stream-using packages, like gulp.)

@MylesBorins
Copy link
Contributor

@chrisdickinson can you make a short list of stream based packages you would like to see added to citgm?

I'd be more than happy to add them then run the smoke-testing suite

@MylesBorins
Copy link
Contributor

current lookup for reference --> https://github.com/nodejs/citgm/blob/master/lib/lookup.json

This changes the behaviour of error event emitted when writing to a stream
after it has ended, from synchronously to asynchronously.

PR-URL: nodejs#4749
@phillipj phillipj force-pushed the emit-ws-end-error-nt branch from 76f6165 to 1899689 Compare January 21, 2016 19:47
@phillipj
Copy link
Member Author

I just created these citgm reports @chrisdickinson:

This PR

Flaky Modules

  • express
    • version 4.13.3
    • Error: The canary is dead.
  • react
    • version 0.14.6
    • Error: Install Failed

v4.2.5

Flaky Modules

  • express
    • version 4.13.3
    • Error: The canary is dead.

v5.5.0

Flaky Modules

  • express
    • version 4.13.3
    • Error: The canary is dead.
  • socket.io
    • version 1.4.4
    • Error: The canary is dead.
  • react
    • version 0.14.6
    • Error: Install Failed

P.S. react fails deliberately as it requires v4.x obviously.

@jasnell
Copy link
Member

jasnell commented Jan 23, 2016

Unfortunately I think failures on those in citgm are common. @thealphanerd can say for sure tho

@MylesBorins
Copy link
Contributor

Those are all expected 😄

@MylesBorins
Copy link
Contributor

fwiw I think @chrisdickinson wanted to add more modules to citgm that were focused on streams.

@chrisdickinson
Copy link
Contributor

I might see if @phated can recommend some modules from the Gulp ecosystem.

@phated
Copy link
Contributor

phated commented Jan 25, 2016

@chrisdickinson what are you looking for?

@jasnell
Copy link
Member

jasnell commented Jan 27, 2016

@phated ... we'd like to get a handful of stream-related modules to add to our smoke-testing infrastructure (http://github.com/nodejs/citgm). We run the tests for every new release and to get an idea of whether a particular change will break the ecosystem.

@phated
Copy link
Contributor

phated commented Jan 31, 2016

vinyl, vinyl-fs, probably something like gulp-jade or other popular plugins (I don't have actual numbers on any of that)

The most important one is probably vinyl-fs which will be receiving even more tests coming up very soon.

@jasnell
Copy link
Member

jasnell commented Feb 1, 2016

@phated... excellent. /cc @thealphanerd

@MylesBorins
Copy link
Contributor

I've opened a PR adding vinyl, vinyl-fs, and readable-stream to citgm.

I'm open to other suggestions

nodejs/citgm#68

@phillipj
Copy link
Member Author

Updated results after mentioned updates to citgm ^^

Flaky Modules

  • socket.io
    • version 1.4.5
    • Error: The canary is dead.
  • react
    • version 0.14.7
    • Error: Install Failed
  • spdy
    • version 3.2.0
    • Error: The canary is dead.

Identical results ran on master and this branch/PR, in other words doesn't seem like this PR introduces more failures..

@thealphanerd is the spdy failure expected?

@jasnell
Copy link
Member

jasnell commented Mar 2, 2016

FWIW, still LGTM /cc @nodejs/ctc

@jasnell
Copy link
Member

jasnell commented Mar 2, 2016

Actually.. looks like this change is also applied in #5251 ... may be able to close this in favor of that one

@phillipj
Copy link
Member Author

phillipj commented Mar 2, 2016

Yep, surely looks like we've done some duplicate work on this one. As #5251 fixes alot more of these issues, I'll close this one and re-open if the other one doesn't land.

@phillipj phillipj closed this Mar 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major PRs that contain breaking changes and should be released in the next major version. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.