@@ -401,3 +401,20 @@ function makeATestWritableStream(writeFunc) {
|
401 | 401 | assert.strictEqual(d.writable, false); |
402 | 402 | })); |
403 | 403 | } |
| 404 | + |
| 405 | +// When the readable side errors, the error must propagate to the writable side. |
| 406 | +{ |
| 407 | +const expectedErr = new Error('readable error'); |
| 408 | +const r = new Readable({ read() {} }); |
| 409 | +const w = new Writable({ |
| 410 | +write(chunk, encoding, callback) { callback(); }, |
| 411 | +}); |
| 412 | +const d = Duplex.from({ readable: r, writable: w }); |
| 413 | +d.on('error', common.mustCall((err) => { |
| 414 | +assert.strictEqual(err, expectedErr); |
| 415 | +})); |
| 416 | +w.on('error', common.mustCall((err) => { |
| 417 | +assert.strictEqual(err, expectedErr); |
| 418 | +})); |
| 419 | +r.destroy(expectedErr); |
| 420 | +} |