Repository navigation
Commit 31f099b
committed
stream: do not detach error listener when stream is already destroyed
When an async iterator runs on a Readable stream with autoDestroy: false
that was destroyed before iteration started, finalize() took the detach
branch because autoDestroy was false. This called cleanup(), removing the
eos error listener before the stream's asynchronous _destroy completed.
When _destroy subsequently finished, emitErrorNT emitted an unhandled
'error' event on a stream with no listeners, crashing the process even
though the iteration error was caught by the consumer.
Allow already-destroyed streams to take the finalize path without
prematurely detaching the error listener.
Fixes: #67418
Signed-off-by: rudy-07 <kanhaiffco2007@gmail.com>1 parent 50ce73f commit 31f099b
2 files changed
Lines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1613 | 1613 | | |
1614 | 1614 | | |
1615 | 1615 | | |
1616 | | - | |
| 1616 | + | |
1617 | 1617 | | |
1618 | 1618 | | |
1619 | 1619 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
634 | 662 | | |
635 | 663 | | |
636 | 664 | | |
| |||
0 commit comments