| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4e782c9 commit 188896e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -617,10 +617,11 @@ function callFinal(stream, state) { | |||
| 617 | 617 | state.pendingcb--; | |
| 618 | 618 | if (err) { | |
| 619 | 619 | errorOrDestroy(stream, err); | |
| 620 | + } else { | ||
| 621 | + state.prefinished = true; | ||
| 622 | + stream.emit('prefinish'); | ||
| 623 | + finishMaybe(stream, state); | ||
| 620 | 624 | } | |
| 621 | - state.prefinished = true; | ||
| 622 | - stream.emit('prefinish'); | ||
| 623 | - finishMaybe(stream, state); | ||
| 624 | 625 | }); | |
| 625 | 626 | } | |
| 626 | 627 | function prefinish(stream, state) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -441,3 +441,20 @@ const helloWorldBuffer = Buffer.from('hello world'); | |||
| 441 | 441 | w.write('hello'); | |
| 442 | 442 | w.destroy(new Error()); | |
| 443 | 443 | } | |
| 444 | + | ||
| 445 | + { | ||
| 446 | + // Verify that finish is not emitted after error | ||
| 447 | + const w = new W(); | ||
| 448 | + | ||
| 449 | + w._final = common.mustCall(function(cb) { | ||
| 450 | + cb(new Error()); | ||
| 451 | + }); | ||
| 452 | + w._write = function(chunk, e, cb) { | ||
| 453 | + process.nextTick(cb); | ||
| 454 | + }; | ||
| 455 | + w.on('error', common.mustCall()); | ||
| 456 | + w.on('prefinish', common.mustNotCall()); | ||
| 457 | + w.on('finish', common.mustNotCall()); | ||
| 458 | + w.write(Buffer.allocUnsafe(1)); | ||
| 459 | + w.end(Buffer.allocUnsafe(0)); | ||
| 460 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments