Title: fs.createReadStream() with highWaterMark: 0 ends without reading any data · Issue #67667 · nodejs/node · GitHub
Open Graph Title: fs.createReadStream() with highWaterMark: 0 ends without reading any data · Issue #67667 · nodejs/node
X Title: fs.createReadStream() with highWaterMark: 0 ends without reading any data · Issue #67667 · nodejs/node
Description: Version v24.22.0, also on main (e8c279d) Platform Darwin 27.2.0 arm64 Subsystem fs What steps will reproduce the bug? 'use strict'; const fs = require('node:fs'); const chunks = []; fs.createReadStream(__filename, { highWaterMark: 0 }) ....
Open Graph Description: Version v24.22.0, also on main (e8c279d) Platform Darwin 27.2.0 arm64 Subsystem fs What steps will reproduce the bug? 'use strict'; const fs = require('node:fs'); const chunks = []; fs.createReadSt...
X Description: Version v24.22.0, also on main (e8c279d) Platform Darwin 27.2.0 arm64 Subsystem fs What steps will reproduce the bug? 'use strict'; const fs = require('node:fs'); const chunks = [];...
Opengraph URL: https://github.com/nodejs/node/issues/67667
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fs.createReadStream() with highWaterMark: 0 ends without reading any data","articleBody":"### Version\n\nv24.22.0, also on main (e8c279d731f)\n\n### Platform\n\n```text\nDarwin 27.2.0 arm64\n```\n\n### Subsystem\n\nfs\n\n### What steps will reproduce the bug?\n\n```js\n'use strict';\nconst fs = require('node:fs');\n\nconst chunks = [];\nfs.createReadStream(__filename, { highWaterMark: 0 })\n .on('data', (chunk) => chunks.push(chunk))\n .on('end', () => {\n console.log('read', Buffer.concat(chunks).length, 'of', fs.statSync(__filename).size, 'bytes');\n });\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways, when the stream's `highWaterMark` is 0. On main this also happens for every `fs.ReadStream` after `stream.setDefaultHighWaterMark(false, 0)`, since #66956.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`read 291 of 291 bytes`. `highWaterMark: 0` means \"do not buffer ahead\", not \"read nothing\". A plain `Readable` with `highWaterMark: 0` still delivers all its data.\n\n### What do you see instead?\n\n`read 0 of 291 bytes`. The stream emits `'end'` without any `'data'`.\n\n### Additional information\n\n`ReadStream.prototype._read(n)` gets `n = highWaterMark = 0`, clamps it with `MathMin(end - pos + 1, n)`, and then `if (n \u003c= 0) this.push(null)` ends the stream: https://github.com/nodejs/node/blob/e8c279d731f2c0eb6eaff03cd341fad469498107/lib/internal/fs/streams.js#L277-L285\n\nThis came up in the review of #66956 (thanks @mertcanaltin). I have a fix ready and will open a PR.\n","author":{"url":"https://github.com/hamzakargin","@type":"Person","name":"hamzakargin"},"datePublished":"2026-11-21T07:01:03Z","url":"https://github.com/nodejs/node/issues/67667"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2025f22a-2679-ce9c-5c0e-0b140edb8ca9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E526:187C1E:C05B20:FE9528:6B01C49B |
| html-safe-nonce | bf1578e0ba361e003d15b19e41d9f826c8eb90ef93a962c99dea99c515052e6d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTI2OjE4N0MxRTpDMDVCMjA6RkU5NTI4OjZCMDFDNDlCIiwidmlzaXRvcl9pZCI6Ijg1NTg5OTE3NDY3MjQzODE4NTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9f0617780bb7f50b0248c15c3e28eb2212fd1c2287495ac2dc3a5ea4fd16d6d4 |
| hovercard-subject-tag | issue:6525768258 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/67667/issue_layout |
| twitter:image | https://opengraph.githubassets.com/886b0d5ca7247f023bcde52a45f9bb70a7af49feaf8b1475f15dff020be3c599/nodejs/node/issues/67667 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/886b0d5ca7247f023bcde52a45f9bb70a7af49feaf8b1475f15dff020be3c599/nodejs/node/issues/67667 |
| og:image:alt | Version v24.22.0, also on main (e8c279d) Platform Darwin 27.2.0 arm64 Subsystem fs What steps will reproduce the bug? 'use strict'; const fs = require('node:fs'); const chunks = []; fs.createReadSt... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hamzakargin |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width