Title: Bug in fileHandle.readableWebStream implementation · Issue #58817 · nodejs/node · GitHub
Open Graph Title: Bug in fileHandle.readableWebStream implementation · Issue #58817 · nodejs/node
X Title: Bug in fileHandle.readableWebStream implementation · Issue #58817 · nodejs/node
Description: Version v24.2.0 Platform Darwin mac.igd.fraunhofer.de 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:25 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6020 arm64 Subsystem No response What steps will reproduce the bug? Start the ...
Open Graph Description: Version v24.2.0 Platform Darwin mac.igd.fraunhofer.de 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:25 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6020 arm64 Subsystem No response What ...
X Description: Version v24.2.0 Platform Darwin mac.igd.fraunhofer.de 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:25 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6020 arm64 Subsystem No response What ...
Opengraph URL: https://github.com/nodejs/node/issues/58817
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug in fileHandle.readableWebStream implementation","articleBody":"### Version\n\nv24.2.0\n\n### Platform\n\n```text\nDarwin mac.igd.fraunhofer.de 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:25 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6020 arm64\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\nStart the attached script.\n\n[bug.zip](https://github.com/user-attachments/files/20888817/bug.zip)\n\n```mjs\n#!/usr/bin/env node\n\nimport * as fsPromises from 'node:fs/promises';\n\nconst scriptURL = new URL(import.meta.url);\nconst fileHandle = await fsPromises.open(scriptURL);\nconst readableStream = fileHandle.readableWebStream();\nconst reader = readableStream.getReader({ mode: \"byob\" });\nconst arrayBuffer = new ArrayBuffer(3);\nconst view = new Uint8Array(arrayBuffer, 2, 1);\nconst result = await reader.read(view);\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nI do not expect to get an exception.\n\n### What do you see instead?\n\nI do get the following exception:\n\n```\nnode:internal/fs/promises:689\n validateOffsetLengthRead(offset, length, buffer.byteLength);\n ^\n\nRangeError [ERR_OUT_OF_RANGE]: The value of \"length\" is out of range. It must be \u003c= -1. Received 1\n at read (node:internal/fs/promises:689:3)\n at fsCall (node:internal/fs/promises:467:18)\n at FileHandle.read (node:internal/fs/promises:199:12)\n at Object.pull (node:internal/fs/promises:322:37)\n at invokePromiseCallback (node:internal/webstreams/util:172:10)\n at Object.\u003canonymous> (node:internal/webstreams/util:177:23)\n at readableByteStreamControllerCallPullIfNeeded (node:internal/webstreams/readablestream:3145:24)\n at node:internal/webstreams/readablestream:3295:7 {\n code: 'ERR_OUT_OF_RANGE'\n}\n\nNode.js v24.2.0\n```\n\n### Additional information\n\nThere seems to be a bug in line 321 of \"node/lib/internal/fs/promises.js\". The line currently looks like this:\n\n```\nconst { bytesRead } = await readFn(view, view.byteOffset, view.byteLength);\n```\n\nIt probably should look like this:\n\n```\nconst { bytesRead } = await readFn(view, 0, view.byteLength);\n```\n\nYou want to read to offset 0 of the Uint8Array \"view\", not to the byteOffset of its underlying ArrayBuffer.\n\nI'm not able to test this fix (I cannot build node.js myself).","author":{"url":"https://github.com/pdaehne","@type":"Person","name":"pdaehne"},"datePublished":"2025-06-24T17:49:45Z","url":"https://github.com/nodejs/node/issues/58817"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:21763149-56fa-f786-e8de-f13e829e395c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DCC8:2A3161:7748B:9C408:6AED047A |
| html-safe-nonce | 8506261e73879544f21e53b1a0c1514fd8488b3d07998758a068db673da44be1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0M4OjJBMzE2MTo3NzQ4Qjo5QzQwODo2QUVEMDQ3QSIsInZpc2l0b3JfaWQiOiIzMTcxNjIzNTE5MjYyNjcxOTk0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5b95fe7162b324db13ed032d71d0864f50f2d5675499137d5bf8c9ac7b251387 |
| hovercard-subject-tag | issue:3172813096 |
| 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/58817/issue_layout |
| twitter:image | https://opengraph.githubassets.com/154b381032116e14f15c16f0ba2a8710b87498d82fa8229adb33ab7281151147/nodejs/node/issues/58817 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/154b381032116e14f15c16f0ba2a8710b87498d82fa8229adb33ab7281151147/nodejs/node/issues/58817 |
| og:image:alt | Version v24.2.0 Platform Darwin mac.igd.fraunhofer.de 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:25 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6020 arm64 Subsystem No response What ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pdaehne |
| hostname | github.com |
| expected-hostname | github.com |
| None | 21e10c535436b2122cfb44c76dfb4af296e371850fb60de16776f8a64e5c3ed8 |
| 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 | 302a6d707c3288a5f951258a2fa3e926b8c8f8cf |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width