← Back to Pull requests

fs: restore stack traces of fs/promises readFile and writeFile errors #66757

Closed
unknown closed this pull request without merging on Nov 11, 2026 22:15 UTC
View on GitHub
unknown unknown commented on Oct 15, 2026 10:47 UTC
Author

Since #65327 and #65489, errors from fs.promises.readFile(), writeFile() and
appendFile() have no stack frames. This affects v26.8.0+ (readFile()) and
v26.9.0+ (writeFile(), appendFile()); v24.x and v22.x aren't affected.

# main
Error: ENOENT: no such file or directory, open '/missing/config.json'

# this PR
Error: ENOENT: no such file or directory, open '/missing/config.json'
    at readFile (node:internal/fs/promises:2301:7)
    at async loadConfig ([eval]:4:3)

The stack was captured from a C++ callback with no JS frames on it. This captures
it after the await instead, like the rest of fs/promises. The success path is
unchanged, and the fs/readfile-promises and fs/writefile-promises benchmarks
show no difference.

<details>
<summary>Benchmark results</summary>

$ node benchmark/compare.js --old ./node-main --new ./node-pr --runs 10 \
    --set duration=1 --filter readfile-promises --filter writefile-promises fs

macOS arm64, 10 runs per binary. p-values are from a Welch's t-test; marks p < 0.05.

| benchmark | configuration | main (ops/s) | this PR (ops/s) | change | p-value |
|---|---|--:|--:|--:|--:|
| readfile-promises | concurrent=1 len=1024 encoding='' | 56,875 | 57,183 | +0.54% | 0.49 |
| readfile-promises | concurrent=1 len=1024 encoding='utf-8' | 57,179 | 58,407 | +2.15% | 0.10 |
| readfile-promises | concurrent=1 len=16777216 encoding='' | 749 | 743 | -0.82% | 0.76 |
| readfile-promises | concurrent=1 len=16777216 encoding='utf-8' | 424 | 429 | +1.24% | 0.71 |
| readfile-promises | concurrent=1 len=33554432 encoding='' | 331 | 332 | +0.58% | 0.67 |
| readfile-promises | concurrent=1 len=33554432 encoding='utf-8' | 175 | 173 | -1.25% | 0.62 |
| readfile-promises | concurrent=1 len=4194304 encoding='' | 3,047 | 3,056 | +0.29% | 0.85 |
| readfile-promises | concurrent=1 len=4194304 encoding='utf-8' | 2,578 | 2,627 | +1.93% | 0.62 |
| readfile-promises | concurrent=1 len=524288 encoding='' | 20,307 | 20,203 | -0.51% | 0.80 |
| readfile-promises | concurrent=1 len=524288 encoding='utf-8' | 17,994 | 17,918 | -0.42% | 0.87 |
| readfile-promises | concurrent=1 len=8388608 encoding='' | 1,593 | 1,576 | -1.05% | 0.64 |
| readfile-promises | concurrent=1 len=8388608 encoding='utf-8' | 1,142 | 1,139 | -0.26% | 0.93 |
| readfile-promises | concurrent=10 len=1024 encoding='' | 184,282 | 186,444 | +1.17% | 0.77 |
| readfile-promises | concurrent=10 len=1024 encoding='utf-8' | 185,096 | 177,114 | -4.31% | 0.23 |
| readfile-promises | concurrent=10 len=16777216 encoding='' | 1,564 | 1,593 | +1.87% | 0.44 |
| readfile-promises | concurrent=10 len=16777216 encoding='utf-8' | 438 | 437 | -0.30% | 0.95 |
| readfile-promises | concurrent=10 len=33554432 encoding='' | 797 | 802 | +0.59% | 0.90 |
| readfile-promises | concurrent=10 len=33554432 encoding='utf-8' | 213 | 203 | -4.79% | 0.26 |
| readfile-promises | concurrent=10 len=4194304 encoding='' | 6,222 | 6,135 | -1.38% | 0.32 |
| readfile-promises | concurrent=10 len=4194304 encoding='utf-8' | 2,104 | 2,104 | +0.01% | 1.00 |
| readfile-promises | concurrent=10 len=524288 encoding='' | 29,102 | 30,652 | +5.32% | 0.16 |
| readfile-promises | concurrent=10 len=524288 encoding='utf-8' | 28,673 | 27,922 | -2.62% | 0.63 |
| readfile-promises | concurrent=10 len=8388608 encoding='' | 2,931 | 2,857 | -2.52% | 0.20 |
| readfile-promises | concurrent=10 len=8388608 encoding='utf-8' | 921 | 913 | -0.93% | 0.73 |
| writefile-promises | concurrent=1 size=1024 encodingType='asc' | 26,216 | 26,881 | +2.54% | 0.65 |
| writefile-promises | concurrent=1 size=1024 encodingType='buf' | 24,924 | 26,980 | +8.25% | 0.30 |
| writefile-promises | concurrent=1 size=1024 encodingType='utf' | 25,694 | 25,851 | +0.61% | 0.94 |
| writefile-promises | concurrent=1 size=1048576 encodingType='asc' | 2,830 | 2,870 | +1.39% | 0.78 |
| writefile-promises | concurrent=1 size=1048576 encodingType='buf' | 2,868 | 3,067 | +6.94% | 0.04
|
| writefile-promises | concurrent=1 size=1048576 encodingType='utf' | 2,894 | 2,879 | -0.50% | 0.93 |
| writefile-promises | concurrent=1 size=2 encodingType='asc' | 28,047 | 27,462 | -2.08% | 0.60 |
| writefile-promises | concurrent=1 size=2 encodingType='buf' | 27,610 | 28,756 | +4.15% | 0.46 |
| writefile-promises | concurrent=1 size=2 encodingType='utf' | 29,195 | 28,797 | -1.36% | 0.69 |
| writefile-promises | concurrent=1 size=65535 encodingType='asc' | 21,725 | 21,700 | -0.11% | 0.98 |
| writefile-promises | concurrent=1 size=65535 encodingType='buf' | 22,605 | 25,022 | +10.69% | 0.09 |
| writefile-promises | concurrent=1 size=65535 encodingType='utf' | 19,432 | 20,483 | +5.41% | 0.44 |
| writefile-promises | concurrent=10 size=1024 encodingType='asc' | 28,006 | 26,607 | -5.00% | 0.11 |
| writefile-promises | concurrent=10 size=1024 encodingType='buf' | 26,818 | 26,754 | -0.24% | 0.96 |
| writefile-promises | concurrent=10 size=1024 encodingType='utf' | 27,985 | 26,590 | -4.98% | 0.19 |
| writefile-promises | concurrent=10 size=1048576 encodingType='asc' | 3,049 | 2,819 | -7.52% | 0.14 |
| writefile-promises | concurrent=10 size=1048576 encodingType='buf' | 2,997 | 2,851 | -4.85% | 0.43 |
| writefile-promises | concurrent=10 size=1048576 encodingType='utf' | 2,975 | 2,940 | -1.17% | 0.80 |
| writefile-promises | concurrent=10 size=2 encodingType='asc' | 28,423 | 27,387 | -3.65% | 0.14 |
| writefile-promises | concurrent=10 size=2 encodingType='buf' | 27,868 | 27,790 | -0.28% | 0.94 |
| writefile-promises | concurrent=10 size=2 encodingType='utf' | 27,878 | 27,841 | -0.13% | 0.98 |
| writefile-promises | concurrent=10 size=65535 encodingType='asc' | 24,832 | 23,330 | -6.05% | 0.24 |
| writefile-promises | concurrent=10 size=65535 encodingType='buf' | 24,651 | 25,360 | +2.88% | 0.62 |
| writefile-promises | concurrent=10 size=65535 encodingType='utf' | 22,357 | 22,614 | +1.15% | 0.80 |

1 of 48 configurations is under p < 0.05, about what chance alone gives with
48 comparisons. It's a 1 MiB write (+6.9%), which is above kWriteFileMaxChunkSize
(512 KiB) and doesn't go through the changed code.

</details>

AI-assisted. I reproduced the bug and ran the tests and benchmarks myself.

cc @codebytere

<!--
If you are submitting a pull request for the first time,
check out the guide for first-time contributors for tips and answers to FAQs:
https://github.com/nodejs/node/blob/HEAD/doc/contributing/first-contributions.md

Before submitting a pull request, please read:

  • the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md

  • the commit message formatting guidelines at

  • https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

    For code changes:
    1. Include tests for any bug fixes or new features.
    2. Update documentation if relevant.
    3. Ensure that make -j4 test (UNIX), or vcbuild test (Windows) passes.

    If you believe this PR should be highlighted in the Node.js CHANGELOG
    please add the notable-change label.

    Developer's Certificate of Origin 1.1

    By making a contribution to this project, I certify that:

    (a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

    (b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

    (c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

    (d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
    -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: christianaurichzm Review duration: 39568m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #66757"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository