Commit d52d366
committed
stream: fix Utf8Stream flush handling
Fix several issues with `Utf8Stream` flushing:
* `flush()` now writes buffered data regardless of `minLength`
and invokes the callback only after pending writes complete,
including when `minLength` is zero and a write is in flight.
* Multiple concurrent `flush()` calls are tracked correctly and
`end()` waits for pending flushes before closing.
* `flushSync()` throws `ERR_INVALID_STATE` if called while an
asynchronous write is in progress instead of corrupting output.
* Periodic flushes no longer stack up while a flush is pending.
* `fsync` is skipped for stdout/stderr file descriptors.
* `reopen()`, `end()` and `destroy()` behave correctly when the
stream is destroyed while still opening.
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode1 parent f4d2742 commit d52d366
6 files changed
Lines changed: 698 additions & 73 deletions
File tree
- doc/api
- lib/internal/streams
- test/parallel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8563 | 8563 | | |
8564 | 8564 | | |
8565 | 8565 | | |
8566 | | - | |
8567 | | - | |
| 8566 | + | |
| 8567 | + | |
| 8568 | + | |
| 8569 | + | |
| 8570 | + | |
8568 | 8571 | | |
8569 | 8572 | | |
8570 | 8573 | | |
8571 | 8574 | | |
8572 | 8575 | | |
| 8576 | + | |
| 8577 | + | |
| 8578 | + | |
| 8579 | + | |
8573 | 8580 | | |
8574 | 8581 | | |
8575 | 8582 | | |
| |||
0 commit comments