Title: Readable with construct() and highWaterMark: 0 hangs in toArray() and for await · Issue #67668 · nodejs/node · GitHub
Open Graph Title: Readable with construct() and highWaterMark: 0 hangs in toArray() and for await · Issue #67668 · nodejs/node
X Title: Readable with construct() and highWaterMark: 0 hangs in toArray() and for await · Issue #67668 · nodejs/node
Description: Version v24.22.0, also on main (e8c279d) Platform Darwin 27.2.0 arm64 Subsystem stream What steps will reproduce the bug? 'use strict'; const { Readable } = require('node:stream'); const chunks = ['a', 'b']; const stream = new Readable({...
Open Graph Description: Version v24.22.0, also on main (e8c279d) Platform Darwin 27.2.0 arm64 Subsystem stream What steps will reproduce the bug? 'use strict'; const { Readable } = require('node:stream'); const chunks = [...
X Description: Version v24.22.0, also on main (e8c279d) Platform Darwin 27.2.0 arm64 Subsystem stream What steps will reproduce the bug? 'use strict'; const { Readable } = require('node:stream'); ...
Opengraph URL: https://github.com/nodejs/node/issues/67668
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Readable with construct() and highWaterMark: 0 hangs in toArray() and for await","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\nstream\n\n### What steps will reproduce the bug?\n\n```js\n'use strict';\nconst { Readable } = require('node:stream');\n\nconst chunks = ['a', 'b'];\nconst stream = new Readable({\n highWaterMark: 0,\n construct(callback) {\n setImmediate(callback);\n },\n read() {\n this.push(chunks.length ? chunks.shift() : null);\n },\n});\n\nlet done = false;\nstream.toArray().then((data) => {\n done = true;\n console.log('done', data.map(String));\n});\nprocess.on('exit', () => {\n if (!done) console.log('toArray() never resolved');\n});\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways, when a `Readable` has `construct()` and `highWaterMark: 0`, and it is consumed with `read()` (`toArray()`, `for await`, a `'readable'` listener). Sync and async `construct()` both hang. Flowing mode (`'data'`) works.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`done [ 'a', 'b' ]`, the same as without `construct()`. With `highWaterMark: 1` it resolves too.\n\n### What do you see instead?\n\n`toArray() never resolved`. `_read()` is never called.\n\n### Additional information\n\nA `read()` during `construct()` is refused (https://github.com/nodejs/node/blob/e8c279d731f2c0eb6eaff03cd341fad469498107/lib/internal/streams/readable.js#L787) and leaves `needReadable` set. When construction finishes, `onConstructed` only calls `maybeReadMore()` (https://github.com/nodejs/node/blob/e8c279d731f2c0eb6eaff03cd341fad469498107/lib/internal/streams/readable.js#L338-L342), which does not read when `highWaterMark` is 0 and the stream is not flowing (https://github.com/nodejs/node/blob/e8c279d731f2c0eb6eaff03cd341fad469498107/lib/internal/streams/readable.js#L957-L959). Nothing calls `_read()` again.\n\n`fs.ReadStream` uses `construct()` too, so `fs.createReadStream(file, { highWaterMark: 0 }).toArray()` hangs for the same reason.\n\nI found this while looking into #67667. 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:41Z","url":"https://github.com/nodejs/node/issues/67668"}
| 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:146ea920-8c18-9781-9e58-d63e70b82354 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D89E:1C94F:22AD12A:2C735BA:6B01C683 |
| html-safe-nonce | 16fb3a360c4c709bb9fb092a15c04eedc16fe5f6a63782c1fc03a07a13b5ce77 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODlFOjFDOTRGOjIyQUQxMkE6MkM3MzVCQTo2QjAxQzY4MyIsInZpc2l0b3JfaWQiOiI0MjM4NTM3NDc0ODM5NzkxMjM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fa16e23754b8e67981c6159dfb91c357fc0300841a3ec60bb77dae0abf6087de |
| hovercard-subject-tag | issue:6525774216 |
| 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/67668/issue_layout |
| twitter:image | https://opengraph.githubassets.com/00364b51bee7b8e4608f5262d3d5fff930c743ed0b79ff5f40216037d89c775d/nodejs/node/issues/67668 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/00364b51bee7b8e4608f5262d3d5fff930c743ed0b79ff5f40216037d89c775d/nodejs/node/issues/67668 |
| og:image:alt | Version v24.22.0, also on main (e8c279d) Platform Darwin 27.2.0 arm64 Subsystem stream What steps will reproduce the bug? 'use strict'; const { Readable } = require('node:stream'); const chunks = [... |
| 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 | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width