MCPcopy Index your code
hub / github.com/nodejs/node / doWriteAndCancel

Function doWriteAndCancel

test/parallel/test-fs-promises-file-handle-writeFile.js:33–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31
32// Signal aborted while writing file
33async function doWriteAndCancel() {
34 const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt');
35 const fileHandle = await open(filePathForHandle, 'w+');
36 try {
37 const buffer = Buffer.from('dogs running'.repeat(512 * 1024), 'utf8');
38 const controller = new AbortController();
39 const { signal } = controller;
40 process.nextTick(() => controller.abort());
41 await assert.rejects(writeFile(fileHandle, buffer, { signal }), {
42 name: 'AbortError'
43 });
44 } finally {
45 await fileHandle.close();
46 }
47}
48
49const dest = path.resolve(tmpDir, 'tmp.txt');
50const otherDest = path.resolve(tmpDir, 'tmp-2.txt');

Calls 6

abortMethod · 0.95
openFunction · 0.70
writeFileFunction · 0.70
closeMethod · 0.65
resolveMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…