fs: read data when highWaterMark is 0 #67669
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.35) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 170 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.308
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #67669"
general
weight: 0.35
christianaurichzm
ReadStream.prototype._read()ended the stream when it was asked for 0 bytes, so anfs.ReadStreamwithhighWaterMark: 0emitted'end'without any data. Since #66956 this also hits everyfs.ReadStreamafterstream.setDefaultHighWaterMark(false, 0).When the requested size is 0, read 64 KiB, the
fs.ReadStreamdefault, instead. The size passed to_read()is only advisory, andgetDefaultHighWaterMark()can't be used here because it also returns 0 aftersetDefaultHighWaterMark(false, 0). Thestart/endlimits still apply.This fixes flowing mode (
'data',pipe()). Consuming such a stream withtoArray()orfor awaitalso needs the fix for #67668, becausefs.ReadStreamusesconstruct().Fixes: https://github.com/nodejs/node/issues/67667
Refs: https://github.com/nodejs/node/pull/66956
Testing: the new
test/parallel/test-fs-read-stream-hwm-zero.jsfails without the fix and passes with it. The related fs, stream, readline, zlib and webstreams tests pass, the fullparallelandsequentialsuites pass locally with both PRs applied, andmake lint-jsis clean.AI disclosure: I used AI coding agents to help investigate the bug and write the fix and the tests. I reviewed the change, reproduced the bug on v24.22.0 and main, and checked the test results above.