-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: fix broken pipeline error propagation
If the destination was an async function any error thrown from that function would be swallowed. Backport-PR-URL: #31975 PR-URL: #31835 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
- Loading branch information
1 parent
8ad64b8
commit 313ecaa
Showing
3 changed files
with
34 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { | ||
pipeline, | ||
PassThrough | ||
} = require('stream'); | ||
const assert = require('assert'); | ||
|
||
process.on('uncaughtException', common.mustCall((err) => { | ||
assert.strictEqual(err.message, 'error'); | ||
})); | ||
|
||
// Ensure that pipeline that ends with Promise | ||
// still propagates error to uncaughtException. | ||
const s = new PassThrough(); | ||
s.end('data'); | ||
pipeline(s, async function(source) { | ||
for await (const chunk of source) { | ||
chunk; | ||
} | ||
}, common.mustCall((err) => { | ||
assert.ifError(err); | ||
throw new Error('error'); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters