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: keep readFile abortable on non-regular files by christianaurichzm · Pull Request #66940 · nodejs/node

Conversation

@christianaurichzm

@christianaurichzm christianaurichzm commented Oct 23, 2026

Copy link
Copy Markdown
Member

fs.readFile() and fs.promises.readFile() ignore an AbortSignal on FIFOs and devices. The read only ends at EOF, so on a FIFO whose writer stays open the abort waits for the writer to close, and on /dev/zero it never ends:

const ac = new AbortController();
setTimeout(() => ac.abort(), 100);
require('fs').promises.readFile('/dev/zero', { signal: ac.signal })
  .catch((err) => console.log(err.name));

v22.23.1 prints AbortError after 100 ms. On main it never does, and memory grows until the process is killed (after 1 s with a 2 GiB limit).

Since #65327, ReadFileJob reads a non-regular file to EOF in one thread pool job and only checks the signal when the job is done. Files over one chunk already go back to the chunked reader, which checks it before each read. Send non-regular files there as well. Regular files that report size 0, like the ones in procfs, are still read in one job. Only v26.8.0+ is affected.

The new test aborts a read on a FIFO and checks that the reader closes it while the writer is still open. It fails on main for both APIs and passes with the fix. fs tests, C++ lint/format and ESLint pass on Linux x64.

Refs: #65327

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@christianaurichzm
fs: keep readFile abortable on non-regular files
10ebd2a
`ReadFileJob` treats a file that is not a regular file as size 0 and
reads it to EOF inside one thread pool job, so the `AbortSignal` is
only checked once the job ends. `fs.readFile()` and
`fs.promises.readFile()` on a FIFO whose writer stays open therefore
do not settle until the writer closes, and on `/dev/zero` they keep
growing the buffer until the process runs out of memory.

Hand the fd back to the chunked reader for non-regular files, the path
files larger than one chunk already take. It checks the signal before
each read. Regular files that report size 0, such as procfs files, are
still read in one job.

Signed-off-by: Christian Aurich Zanettini Martins <[email protected]>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Oct 23, 2026
@codecov

codecov Bot commented Oct 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.59%. Comparing base (44d5d57) to head (10ebd2a).
⚠️ Report is 239 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66940      +/-   ##
==========================================
+ Coverage   90.57%   90.59%   +0.01%     
==========================================
  Files         797      797              
  Lines      278502   278278     -224     
  Branches    53538    53504      -34     
==========================================
- Hits       252267   252106     -161     
+ Misses      16576    16542      -34     
+ Partials     9659     9630      -29     
Files with missing lines Coverage Δ
lib/fs.js 97.17% <100.00%> (+<0.01%) ⬆️
lib/internal/fs/promises.js 91.63% <100.00%> (+0.41%) ⬆️
src/node_file.cc 75.69% <100.00%> (-0.20%) ⬇️

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@christianaurichzm

christianaurichzm commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

@codebytere @jasnell, this follows up on #65327, could you take a look? If it looks good, could you also add request-ci? Thanks!

cc @panva

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax
addaleax approved these changes Oct 30, 2026
View reviewed changes
@addaleax addaleax added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Oct 30, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 30, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78744/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78764/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@christianaurichzm christianaurichzm added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 10, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 6c8a697 into nodejs:main Nov 10, 2026
85 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Landed in 6c8a697

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 10, 2026
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@christianaurichzm @aduh95
fs: keep readFile abortable on non-regular files
0c5be92
`ReadFileJob` treats a file that is not a regular file as size 0 and
reads it to EOF inside one thread pool job, so the `AbortSignal` is
only checked once the job ends. `fs.readFile()` and
`fs.promises.readFile()` on a FIFO whose writer stays open therefore
do not settle until the writer closes, and on `/dev/zero` they keep
growing the buffer until the process runs out of memory.

Hand the fd back to the chunked reader for non-regular files, the path
files larger than one chunk already take. It checks the signal before
each read. Regular files that report size 0, such as procfs files, are
still read in one job.

Signed-off-by: Christian Aurich Zanettini Martins <[email protected]>
PR-URL: #66940
Refs: #65327
Reviewed-By: Anna Henningsen <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 11, 2026
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha) #67415
Merged
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@christianaurichzm @aduh95
fs: keep readFile abortable on non-regular files
3c5f22b
`ReadFileJob` treats a file that is not a regular file as size 0 and
reads it to EOF inside one thread pool job, so the `AbortSignal` is
only checked once the job ends. `fs.readFile()` and
`fs.promises.readFile()` on a FIFO whose writer stays open therefore
do not settle until the writer closes, and on `/dev/zero` they keep
growing the buffer until the process runs out of memory.

Hand the fd back to the chunked reader for non-regular files, the path
files larger than one chunk already take. It checks the signal before
each read. Regular files that report size 0, such as procfs files, are
still read in one job.

Signed-off-by: Christian Aurich Zanettini Martins <[email protected]>
PR-URL: #66940
Refs: #65327
Reviewed-By: Anna Henningsen <[email protected]>
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@christianaurichzm @aduh95
fs: keep readFile abortable on non-regular files
d59e71d
`ReadFileJob` treats a file that is not a regular file as size 0 and
reads it to EOF inside one thread pool job, so the `AbortSignal` is
only checked once the job ends. `fs.readFile()` and
`fs.promises.readFile()` on a FIFO whose writer stays open therefore
do not settle until the writer closes, and on `/dev/zero` they keep
growing the buffer until the process runs out of memory.

Hand the fd back to the chunked reader for non-regular files, the path
files larger than one chunk already take. It checks the signal before
each read. Regular files that report size 0, such as procfs files, are
still read in one job.

Signed-off-by: Christian Aurich Zanettini Martins <[email protected]>
PR-URL: #66940
Refs: #65327
Reviewed-By: Anna Henningsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@addaleax addaleax addaleax approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@christianaurichzm @nodejs-github-bot @addaleax
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.