GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: ensure Stream.pipeline re-emits errors without callback by phated · Pull Request #20437 · nodejs/node

Conversation

@phated

@phated phated commented Apr 30, 2018

Copy link
Copy Markdown
Contributor

Fixes an issue where Stream.pipeline wouldn't re-emit errors
on a stream if no callback was specified, thus swallowing
said errors.

Fixes: #20303

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

stephenlacy reacted with thumbs up emoji bcoe reacted with hooray emoji
All reactions
  • 👍 1 reaction
  • 🎉 1 reaction
@phated

phated commented Apr 30, 2018

Copy link
Copy Markdown
Contributor Author

cc @addaleax @mafintosh

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@phated phated mentioned this pull request Apr 30, 2018
Cleanup before callback mafintosh/end-of-stream#12
Open
addaleax
addaleax approved these changes Apr 30, 2018
View reviewed changes
Comment thread lib/internal/streams/pipeline.js Outdated

@addaleax addaleax Apr 30, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This seems to make sense, but I find it hard to tell how this part of the change relates to the rest. It feels like this should be something that comes with tests too?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@phated phated Apr 30, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@addaleax so i stumbled around for ~2 days on this. Without cleaning up after end-of-stream, my re-emitted error was still being handled by the error handler that end-of-stream attached and I couldn't get an uncaughtException to be emitted. Once I added the cleanup, it emitted with no issues.

Would that go in this PR? A separate commit? I'm not sure the process here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@addaleax addaleax Apr 30, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Okay, makes sense. I think single PR and single commit is fine (but especially in the case of splitting into commits that correspond to logical changes you can use your own judgement). I think you can feel free to add a comment here that describes how this relates to the error handling, but this should be fine as-is.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@phated phated Apr 30, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I've forced pushed an updated comment that describes what I've explained above.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@phated
phated force-pushed the stream-pipeline-reemit-errors branch from a490a89 to d42c4d4 Compare April 30, 2018 22:36
@addaleax addaleax added the stream Issues and PRs related to Node.js streams. label Apr 30, 2018
@addaleax

addaleax commented Apr 30, 2018

Copy link
Copy Markdown
Member

CI: https://ci.nodejs.org/job/node-test-commit/18151/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mafintosh

mafintosh commented May 4, 2018

Copy link
Copy Markdown
Member

Personally I'm 👎 on this. Emitting errors on other streams can have unintended side effects, which is why pipeline/pump tries not to do that in the first place. If all streams were "modern" you could call destroy(err) on them but thats not gonna behave well in streams < node 10 unless they have a custom destroy handler. Changing behavior based whether a cb is passed or not can lead to tricky bugs imo.

If people fell strongly about this I'd make the noop cb throw the error instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented May 4, 2018

Copy link
Copy Markdown
Member

@mafintosh I with @phated in that I think we should definitely do something that does not just swallow the errors silently…

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented May 4, 2018

Copy link
Copy Markdown
Member

I agree with @mafintosh that this is likely not the best approach. Perhaps if pipeline() is not given a callback, a default non-op callback that throws when err is not null would be a better approach?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mafintosh

mafintosh commented May 4, 2018

Copy link
Copy Markdown
Member

@addaleax I wouldn't say errors are swallowed silently. On error the entire pipeline is shut down and destroy handlers are called on all streams. If you wanna be notified about this outside of your stream, you can pass a cb. Lots of use-cases of pump I've seen in the wild don't pass a cb, so if pipeline were to help them they'd have to pass in noop's.

I don't feel strongly though about that part (I do about the re-emitting errors part tho), as pump still exists and gonna keep that old behaivor.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@phated

phated commented May 4, 2018

Copy link
Copy Markdown
Contributor Author

I'm fine if we avoid re-emitting the error and switch it to throwing in the noop - all I really care about is that the error is actually surfaced when there's no way to watch for it (not passing a callback).

Should I update the PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR

BridgeAR commented May 5, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@jasnell if I understand your approach correct you want to do:

pipeline()

function pipeline(callback) {
  callback = callback || (err) => {
    if (err)
      throw err;
  }
  // Do stuff
}

To me this does not seem like a good approach since this will always end up as uncaught exception. Or did I misunderstand something?

I personally suggest to just force the user to always add a callback. If non is added, we just throw an error as we do in other APIs as well. If the user wants to ignore errors, that is totally fine.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@phated

phated commented May 13, 2018

Copy link
Copy Markdown
Contributor Author

@jasnell @addaleax should I update the PR to rethrow in the noop callback?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented May 13, 2018

Copy link
Copy Markdown
Member

@phated I would do that, yes. 👍 It seems like that’s at least something that you, me, @jasnell and @mafintosh can be behind.

I personally suggest to just force the user to always add a callback.

@BridgeAR Also okay with me, but maybe for a follow-up PR since that’s tightening up behaviour even more?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@phated
phated force-pushed the stream-pipeline-reemit-errors branch from d42c4d4 to c636365 Compare May 13, 2018 21:21
addaleax
addaleax approved these changes May 13, 2018
View reviewed changes

@addaleax addaleax left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Still LGTM

CI: https://ci.nodejs.org/job/node-test-commit/18457/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BridgeAR

BridgeAR commented May 18, 2018

Copy link
Copy Markdown
Member

@addaleax

but maybe for a follow-up PR since that’s tightening up behaviour even more

It does tighten the current rule but I highly prefer that over the current PR implementation. I think throwing async is a really bad idea. Using emit would be a way the user could deal with it properly but always triggering uncaught exceptions is 😕

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented May 18, 2018

Copy link
Copy Markdown
Member

Using emit would be a way the user could deal with it properly but always triggering uncaught exceptions is 😕

I agree that generating uncaught exceptions is 😕, but it’s something for which users have a clear way to address.

More practically speaking, I think this PR could pass as not being semver-major (because there are cases where it’s known that no error is going to occur, and for the other cases this is effectively not silencing errors that should not be silenced, so a bug fix) whereas making the callback non-optional is definitely semver-major imo.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented May 23, 2018

Copy link
Copy Markdown
Member

Where are we at on this one? Definitely needs a rebase.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@phated

phated commented May 23, 2018

Copy link
Copy Markdown
Contributor Author

This has been sitting for approval and feedback for a long time and I probably won't have time to rebase this coming up. Can someone else take that on?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 23, 2018

Copy link
Copy Markdown
Member

@mafintosh are you still -1 on this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mafintosh

mafintosh commented May 24, 2018

Copy link
Copy Markdown
Member

@mcollina I think there are plenty of valid usecases where you don't want a cb because all error handling is contained in the pipeline (like a simple pipeline(fs.createReadStream(), httpRes)) so 👎 on that still.

I wouldn't block a merge though if people felt like it's super important.

This change https://github.com/nodejs/node/pull/20437/files#diff-eefad5e8051f1634964a3847b691ff84R49 should not be there IMO though as it makes error handling in practice tricky. With that change if a stream emits an error after end you'll have to setup your own error handling which in practice means you need to do that all the time rendering the API not that useful in many scenarios.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina requested changes May 24, 2018
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Marking my request of change explicit, so it does not get landed accidentally.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/streams/pipeline.js Outdated

@mcollina mcollina May 24, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think this should not be done here. 'error' can still happen after 'end', making error handling more tricky.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BridgeAR

BridgeAR commented May 29, 2018

Copy link
Copy Markdown
Member

@mafintosh as a general thing: you would be strongly against requiring a callback all the time? This is the default for pretty much everything async in Node.js and it would also solve this issue. Every user could easily just add a no-op callback in case they want to ignore that. Adding an explicit documentation about this should probably sufficient to explain this to users, don't you think so?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mafintosh

mafintosh commented May 29, 2018

Copy link
Copy Markdown
Member

@BridgeAR not strongly against it, just personal preference.

BridgeAR reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@phated
stream: ensure Stream.pipeline re-throws errors without callback
44d3fe3
Fixes an issue where Stream.pipeline wouldn't re-throw errors
on a stream if no callback was specified, thus swallowing
said errors.

Fixes: nodejs#20303
@phated
phated force-pushed the stream-pipeline-reemit-errors branch from c636365 to 44d3fe3 Compare May 30, 2018 20:00
@phated

phated commented May 30, 2018

Copy link
Copy Markdown
Contributor Author

@addaleax @mcollina I've made rebased and made the desired changes. Can we get this wrapped up so I don't need to spend even more time rebasing and stuff?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina approved these changes May 30, 2018
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mcollina

mcollina commented May 30, 2018

Copy link
Copy Markdown
Member

CI: https://ci.nodejs.org/job/node-test-pull-request/15171/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina mcollina added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label May 30, 2018
@mcollina

mcollina commented May 30, 2018

Copy link
Copy Markdown
Member

This is ready to land with a green CI.

addaleax and phated reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mafintosh

mafintosh commented May 30, 2018

Copy link
Copy Markdown
Member

👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mafintosh
mafintosh approved these changes May 30, 2018
View reviewed changes
@addaleax

addaleax commented May 31, 2018

Copy link
Copy Markdown
Member

Landed in c1012b4, thanks for the PR!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax closed this May 31, 2018
addaleax pushed a commit that referenced this pull request May 31, 2018
@phated @addaleax
stream: ensure Stream.pipeline re-throws errors without callback
c1012b4
Fixes an issue where Stream.pipeline wouldn't re-throw errors
on a stream if no callback was specified, thus swallowing
said errors.

Fixes: #20303

PR-URL: #20437
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
addaleax pushed a commit that referenced this pull request May 31, 2018
@phated @addaleax
stream: ensure Stream.pipeline re-throws errors without callback
d1e81b0
Fixes an issue where Stream.pipeline wouldn't re-throw errors
on a stream if no callback was specified, thus swallowing
said errors.

Fixes: #20303

PR-URL: #20437
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jun 6, 2018
v10.4.0 proposal #21167
Merged
MylesBorins added a commit that referenced this pull request Jun 6, 2018
@MylesBorins
2018-06-06, Version 10.4.0 (Current)
1e88953
Notable Changes:

* **deps**:
 - update V8 to 6.7.288.43 (Michaël Zasso)
   #19989
* **stream**:
  - ensure Stream.pipeline re-throws errors without callback (Blaine Bublitz)
    #20437

PR-URL: #21167
MylesBorins added a commit that referenced this pull request Jun 6, 2018
@MylesBorins
2018-06-06, Version 10.4.0 (Current)
e5d9198
Notable Changes:

* **deps**:
 - update V8 to 6.7.288.43 (Michaël Zasso)
   #19989
* **stream**:
  - ensure Stream.pipeline re-throws errors without callback (Blaine Bublitz)
    #20437

PR-URL: #21167
@snyk-bot snyk-bot mentioned this pull request Mar 18, 2020
[Snyk] Upgrade: gatsby, gatsby-image, gatsby-plugin-catch-links, gatsby-plugin-manifest, gatsby-plugin-no-sourcemaps, gatsby-plugin-offline, gatsby-plugin-react-helmet, gatsby-plugin-sharp, gatsby-plugin-styled-components, gatsby-remark-autolink-headers, gatsby-remark-prismjs, gatsby-source-filesystem, gatsby-transformer-remark O330oei/node#3
Open
@snyk-bot snyk-bot mentioned this pull request Apr 1, 2020
[Snyk] Upgrade: gatsby, gatsby-image, gatsby-plugin-catch-links, gatsby-plugin-manifest, gatsby-plugin-no-sourcemaps, gatsby-plugin-offline, gatsby-plugin-react-helmet, gatsby-plugin-sharp, gatsby-plugin-styled-components, gatsby-remark-autolink-headers, gatsby-remark-prismjs, gatsby-source-filesystem, gatsby-transformer-remark O330oei/node#10
Open
@mcollina mcollina mentioned this pull request May 27, 2020
Promise-friendly stream.pipeline and stream.finished #33582
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Jul 6, 2026
fix: optimize webm duration patching to prevent crash on long recordings getopenscreen/openscreen#77
Merged
7 of 16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@addaleax addaleax addaleax approved these changes
+1 more reviewer
@mafintosh mafintosh mafintosh approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. stream Issues and PRs related to Node.js streams.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Stream.pipeline does not re-emit errors without callback

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@phated @addaleax @mafintosh @jasnell @BridgeAR @mcollina
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.