Title: fs.openAsBlob reports a missing file as ERR_INVALID_ARG_VALUE, discarding the ENOENT · Issue #65514 · nodejs/node · GitHub
Open Graph Title: fs.openAsBlob reports a missing file as ERR_INVALID_ARG_VALUE, discarding the ENOENT · Issue #65514 · nodejs/node
X Title: fs.openAsBlob reports a missing file as ERR_INVALID_ARG_VALUE, discarding the ENOENT · Issue #65514 · nodejs/node
Description: Version v26.7.0 (reproduced; code path unchanged on main) Platform macOS (Darwin 25.5.0, arm64) — not platform-specific Subsystem fs What steps will reproduce the bug? const { openAsBlob } = require("node:fs"); try { openAsBlob("./does-n...
Open Graph Description: Version v26.7.0 (reproduced; code path unchanged on main) Platform macOS (Darwin 25.5.0, arm64) — not platform-specific Subsystem fs What steps will reproduce the bug? const { openAsBlob } = requir...
X Description: Version v26.7.0 (reproduced; code path unchanged on main) Platform macOS (Darwin 25.5.0, arm64) — not platform-specific Subsystem fs What steps will reproduce the bug? const { openAsBlob } = requir...
Opengraph URL: https://github.com/nodejs/node/issues/65514
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fs.openAsBlob reports a missing file as ERR_INVALID_ARG_VALUE, discarding the ENOENT","articleBody":"### Version\n\nv26.7.0 (reproduced; code path unchanged on `main`)\n\n### Platform\n\nmacOS (Darwin 25.5.0, arm64) — not platform-specific\n\n### Subsystem\n\n`fs`\n\n### What steps will reproduce the bug?\n\n```js\nconst { openAsBlob } = require(\"node:fs\");\ntry {\n openAsBlob(\"./does-not-exist.txt\");\n} catch (error) {\n console.log(error.name, error.code, error.message);\n // TypeError ERR_INVALID_ARG_VALUE Unable to open file as blob\n}\n```\n\nAlways reproduces. Same result for a permission failure — every open/stat failure produces the identical error.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nA rejection (or at least an error) equivalent to what every other `fs` open/stat API produces for a missing file: a system error with `code: \"ENOENT\"`, plus `syscall` and `path`. `ERR_INVALID_ARG_VALUE` (a `TypeError`) says the *argument* is malformed, but the path here is a perfectly valid argument — the file just doesn't exist. The docs for `openAsBlob` don't document any different error contract.\n\n### What do you see instead?\n\n`TypeError [ERR_INVALID_ARG_VALUE]: Unable to open file as blob` — thrown synchronously (the synchronous-throw half is already tracked in #62418), with no `errno`, `syscall`, or `path`. ENOENT, EACCES, and any other underlying failure are indistinguishable.\n\n### Additional information\n\nMechanism:\n\n1. `lib/fs.js` `openAsBlob()` calls `createBlobFromFilePath(path)` synchronously and wraps the result in `PromiseResolve`.\n2. `src/node_blob.cc` `BlobFromFilePath()` calls `DataQueue::CreateFdEntry(env, args[0])` and, when it gets `nullptr`, throws `THROW_ERR_INVALID_ARG_VALUE(env, \"Unable to open file as blob\")`.\n3. `src/dataqueue/queue.cc` `FdEntry::Create()` returns `nullptr` for **any** negative `uv_fs_stat`/open result, discarding the libuv status code — this is where the ENOENT is lost.\n\nNote that the pending fix for #62418 (PR #62655) only converts the synchronous throw into a promise rejection; its new test asserts `code: 'ERR_INVALID_ARG_VALUE'` for `openAsBlob('does-not-exist')`, which would enshrine the misleading code. It would be good to fix the error identity at the same time: have the native side (or `FdEntry::Create`) propagate the uv status and throw a proper `UVException` (`ENOENT`/`EACCES`/… with `syscall`/`path`), as `fs.open` does.\n\nReal-world impact: the generic `ERR_INVALID_ARG_VALUE` sent us debugging \"path validation\" changes for a test-suite failure whose actual cause was simply a cwd-relative path to a file that didn't exist — an `ENOENT` with the path attached would have made it a ten-second diagnosis.\n\nRelated observation while testing (can file separately if preferred): `openAsBlob(\"./some-directory\")` succeeds and returns a `Blob` sized to the directory's stat size; reading it later fails with `NotReadableError: The blob could not be read`. An EISDIR at open time would be more helpful there too.\n","author":{"url":"https://github.com/gildas-lormeau","@type":"Person","name":"gildas-lormeau"},"datePublished":"2026-08-24T12:39:41Z","url":"https://github.com/nodejs/node/issues/65514"}
| 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:1d7d610f-cd7a-9227-d082-a192f82706e1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D624:278FD:655651:83E639:6AED2D8B |
| html-safe-nonce | 9d757c7428ff639c0df885b972f4931ef5508c086b18b975a29c7f414c97cd8e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjI0OjI3OEZEOjY1NTY1MTo4M0U2Mzk6NkFFRDJEOEIiLCJ2aXNpdG9yX2lkIjoiMzE2Njg5Mzg0NTQ0MTc1MjQ1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 45461c01cb4b5548ad76f19eeddb512eb1c1182bf060da813a45b945f286107a |
| hovercard-subject-tag | issue:5234804837 |
| 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/65514/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a08fd55d5d87a0358f32bb02dbcfad46f6178ef3013363a135de6a3f98ee34dc/nodejs/node/issues/65514 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a08fd55d5d87a0358f32bb02dbcfad46f6178ef3013363a135de6a3f98ee34dc/nodejs/node/issues/65514 |
| og:image:alt | Version v26.7.0 (reproduced; code path unchanged on main) Platform macOS (Darwin 25.5.0, arm64) — not platform-specific Subsystem fs What steps will reproduce the bug? const { openAsBlob } = requir... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gildas-lormeau |
| hostname | github.com |
| expected-hostname | github.com |
| None | e51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a |
| 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 | 59ebb7b901cc154ecc179a44f266fcf69f343b30 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width