GeezerVison is showing github.com — stream: fix Utf8Stream flush handling · nodejs/node@c27b3ad
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 |
|---|
@@ -8417,13 +8417,20 @@ Close the stream gracefully, flushing the internal buffer before closing. |
8417 | 8417 | * `callback` {Function} |
8418 | 8418 | * `err` {Error|null} An error if the flush failed, otherwise `null`. |
8419 | 8419 |
|
8420 | | -Writes the current buffer to the file if a write was not in progress. Do |
8421 | | -nothing if `minLength` is zero or if it is already writing. |
| 8420 | +Writes the current buffer to the file. The callback is invoked after pending |
| 8421 | +writes complete and, unless the `fsync` option is enabled, after the data has |
| 8422 | +been synchronized with `fs.fsync()`. `fsync` errors indicating that the file |
| 8423 | +descriptor does not support synchronization (for example, a pipe or a TTY) |
| 8424 | +are ignored. |
8422 | 8425 |
|
8423 | 8426 | #### `utf8Stream.flushSync()` |
8424 | 8427 |
|
8425 | 8428 | Flushes the buffered data synchronously. This is a costly operation. |
8426 | 8429 |
|
| 8430 | +If an asynchronous write is in flight when `flushSync()` is called, only the |
| 8431 | +data queued after it is written, and it may reach the file before the data |
| 8432 | +of the in-flight write. |
| 8433 | +
|
8427 | 8434 | #### `utf8Stream.fsync` |
8428 | 8435 |
|
8429 | 8436 | * {boolean} Whether the stream is performing a `fs.fsyncSync()` after every |
|