-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
streams: forward errors correctly for duplexPair endpoints #61098
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||||||||
| 'use strict'; | ||||||||||||
|
|
||||||||||||
| const common = require('../common'); | ||||||||||||
| const assert = require('assert'); | ||||||||||||
| const { duplexPair } = require('stream'); | ||||||||||||
|
|
||||||||||||
| const [sideA, sideB] = duplexPair(); | ||||||||||||
|
|
||||||||||||
| let sideAErrorReceived = false; | ||||||||||||
| let sideBErrorReceived = false; | ||||||||||||
|
|
||||||||||||
| // Use common.mustCall inside the listeners to ensure they trigger | ||||||||||||
| sideA.on('error', common.mustCall((err) => { | ||||||||||||
| sideAErrorReceived = true; | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
You might want to check that the error is the expected one instead. |
||||||||||||
| })); | ||||||||||||
|
|
||||||||||||
| sideB.on('error', common.mustCall((err) => { | ||||||||||||
| sideBErrorReceived = true; | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Ditto. |
||||||||||||
| })); | ||||||||||||
|
|
||||||||||||
| sideA.resume(); | ||||||||||||
| sideB.resume(); | ||||||||||||
|
|
||||||||||||
| sideB.destroy(new Error('Simulated error')); | ||||||||||||
|
|
||||||||||||
| // Wrap the callback in common.mustCall() | ||||||||||||
| setImmediate(common.mustCall(() => { | ||||||||||||
| assert.strictEqual(sideAErrorReceived, true); | ||||||||||||
| assert.strictEqual(sideBErrorReceived, true); | ||||||||||||
| })); | ||||||||||||
|
Comment on lines
+26
to
+30
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
common.mustCall() as a listener for the |
||||||||||||
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.