Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ changes:
* `data` {string|Buffer|TypedArray|DataView|AsyncIterable|Iterable|Stream}
* `options` {Object|string}
* `encoding` {string|null} **Default:** `'utf8'`
* `flush` {boolean} If `true`, the underlying file descriptor is flushed
prior to closing it. **Default:** `false`.
* `signal` {AbortSignal|undefined} allows aborting an in-progress writeFile. **Default:** `undefined`
* Returns: {Promise} Fulfills with `undefined` upon success.

Alias of [`filehandle.writeFile()`][].
Expand Down
21 changes: 18 additions & 3 deletions test/parallel/test-fs-promises-file-handle-append-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ async function validateAppendString() {
await fileHandle.close();
}

validateAppendBuffer()
.then(validateAppendString)
.then(common.mustCall());
async function doAppendAndCancel() {
const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt');
const fileHandle = await open(filePathForHandle, 'w+');
const buffer = Buffer.from('dogs running'.repeat(512 * 1024), 'utf8');
const controller = new AbortController();
const { signal } = controller;
process.nextTick(() => controller.abort());
await assert.rejects(fileHandle.appendFile(buffer, { signal }), {
name: 'AbortError'
});
await fileHandle.close();
}

Promise.all([
validateAppendBuffer(),
validateAppendString(),
doAppendAndCancel(),
]).then(common.mustCall());
Loading