GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: fix writeFile signal does not close file · nodejs/node@f2279f8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • fs.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ function readFile(path, options, callback) {
334334
return;
335335
}
336336

337+
if (options.signal?.aborted) {
338+
callback(lazyDOMException('The operation was aborted', 'AbortError'));
339+
return;
340+
}
341+
337342
const flagsNumber = stringToFlags(options.flag);
338343
path = getValidatedPath(path);
339344

@@ -1440,7 +1445,13 @@ function lutimesSync(path, atime, mtime) {
14401445

14411446
function writeAll(fd, isUserFd, buffer, offset, length, signal, callback) {
14421447
if (signal?.aborted) {
1443-
callback(lazyDOMException('The operation was aborted', 'AbortError'));
1448+
if (isUserFd) {
1449+
callback(lazyDOMException('The operation was aborted', 'AbortError'));
1450+
} else {
1451+
fs.close(fd, function() {
1452+
callback(lazyDOMException('The operation was aborted', 'AbortError'));
1453+
});
1454+
}
14441455
return;
14451456
}
14461457
// write(fd, buffer, offset, length, position, callback)

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.