GeezerVison is showing github.com — stream: fix Utf8Stream flush handling · nodejs/node@112af9e
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/fs.md +9-2Lines changed: 9 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8508,13 +8508,20 @@ Close the stream gracefully, flushing the internal buffer before closing. |
8508 | 8508 | * `callback` {Function} |
8509 | 8509 | * `err` {Error|null} An error if the flush failed, otherwise `null`. |
8510 | 8510 |
|
8511 | | -Writes the current buffer to the file if a write was not in progress. Do |
8512 | | -nothing if `minLength` is zero or if it is already writing. |
| 8511 | +Writes the current buffer to the file. The callback is invoked after pending |
| 8512 | +writes complete and, unless the `fsync` option is enabled, after the data has |
| 8513 | +been synchronized with `fs.fsync()`. `fsync` errors indicating that the file |
| 8514 | +descriptor does not support synchronization (for example, a pipe or a TTY) |
| 8515 | +are ignored. |
8513 | 8516 |
|
8514 | 8517 | #### `utf8Stream.flushSync()` |
8515 | 8518 |
|
8516 | 8519 | Flushes the buffered data synchronously. This is a costly operation. |
8517 | 8520 |
|
| 8521 | +If an asynchronous write is in flight when `flushSync()` is called, only the |
| 8522 | +data queued after it is written, and it may reach the file before the data |
| 8523 | +of the in-flight write. |
| 8524 | +
|
8518 | 8525 | #### `utf8Stream.fsync` |
8519 | 8526 |
|
8520 | 8527 | * {boolean} Whether the stream is performing a `fs.fsyncSync()` after every |
|