Repository navigation
fs: restore stack traces of fs/promises readFile and writeFile errors - #66757
Open
vedchaudhari wants to merge 1 commit into
Open
vedchaudhari wants to merge 1 commit into
vedchaudhari wants to merge 1 commit into
Conversation
Errors from readFile(), writeFile() and appendFile() have had no stack frames since they started using a single thread pool round trip, as the stack was captured from a C++ callback with no JS frames on it. Capture it after the await instead, like the rest of fs/promises. Refs: nodejs#65327 Refs: nodejs#65489 Assisted-by: claude:opus-5.5 Signed-off-by: vedchaudhari <vedc2853@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #66757 +/- ##
=======================================
Coverage 90.49% 90.49%
=======================================
Files 797 797
Lines 277494 277517 +23
Branches 53321 53327 +6
=======================================
+ Hits 251115 251144 +29
+ Misses 16802 16794 -8
- Partials 9577 9579 +2
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Since #65327 and #65489, errors from
fs.promises.readFile(),writeFile()andappendFile()have no stack frames. This affects v26.8.0+ (readFile()) andv26.9.0+ (
writeFile(),appendFile()); v24.x and v22.x aren't affected.The stack was captured from a C++ callback with no JS frames on it. This captures
it after the
awaitinstead, like the rest offs/promises. The success path isunchanged, and the
fs/readfile-promisesandfs/writefile-promisesbenchmarksshow no difference.
Benchmark results
macOS arm64, 10 runs per binary. p-values are from a Welch's t-test;
*marks p < 0.05.concurrent=1 len=1024 encoding=''concurrent=1 len=1024 encoding='utf-8'concurrent=1 len=16777216 encoding=''concurrent=1 len=16777216 encoding='utf-8'concurrent=1 len=33554432 encoding=''concurrent=1 len=33554432 encoding='utf-8'concurrent=1 len=4194304 encoding=''concurrent=1 len=4194304 encoding='utf-8'concurrent=1 len=524288 encoding=''concurrent=1 len=524288 encoding='utf-8'concurrent=1 len=8388608 encoding=''concurrent=1 len=8388608 encoding='utf-8'concurrent=10 len=1024 encoding=''concurrent=10 len=1024 encoding='utf-8'concurrent=10 len=16777216 encoding=''concurrent=10 len=16777216 encoding='utf-8'concurrent=10 len=33554432 encoding=''concurrent=10 len=33554432 encoding='utf-8'concurrent=10 len=4194304 encoding=''concurrent=10 len=4194304 encoding='utf-8'concurrent=10 len=524288 encoding=''concurrent=10 len=524288 encoding='utf-8'concurrent=10 len=8388608 encoding=''concurrent=10 len=8388608 encoding='utf-8'concurrent=1 size=1024 encodingType='asc'concurrent=1 size=1024 encodingType='buf'concurrent=1 size=1024 encodingType='utf'concurrent=1 size=1048576 encodingType='asc'concurrent=1 size=1048576 encodingType='buf'concurrent=1 size=1048576 encodingType='utf'concurrent=1 size=2 encodingType='asc'concurrent=1 size=2 encodingType='buf'concurrent=1 size=2 encodingType='utf'concurrent=1 size=65535 encodingType='asc'concurrent=1 size=65535 encodingType='buf'concurrent=1 size=65535 encodingType='utf'concurrent=10 size=1024 encodingType='asc'concurrent=10 size=1024 encodingType='buf'concurrent=10 size=1024 encodingType='utf'concurrent=10 size=1048576 encodingType='asc'concurrent=10 size=1048576 encodingType='buf'concurrent=10 size=1048576 encodingType='utf'concurrent=10 size=2 encodingType='asc'concurrent=10 size=2 encodingType='buf'concurrent=10 size=2 encodingType='utf'concurrent=10 size=65535 encodingType='asc'concurrent=10 size=65535 encodingType='buf'concurrent=10 size=65535 encodingType='utf'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.
AI-assisted. I reproduced the bug and ran the tests and benchmarks myself.
cc @codebytere