Title: fs: rmSync() reports UV_UNKNOWN with an empty code for unmapped errno values · Issue #65884 · nodejs/node · GitHub
Open Graph Title: fs: rmSync() reports UV_UNKNOWN with an empty code for unmapped errno values · Issue #65884 · nodejs/node
X Title: fs: rmSync() reports UV_UNKNOWN with an empty code for unmapped errno values · Issue #65884 · nodejs/node
Description: Node.js JavaScript runtime ✨🐢🚀✨. Contribute to nodejs/node development by creating an account on GitHub.
Open Graph Description: Node.js JavaScript runtime ✨🐢🚀✨. Contribute to nodejs/node development by creating an account on GitHub.
X Description: Node.js JavaScript runtime ✨🐢🚀✨. Contribute to nodejs/node development by creating an account on GitHub.
Opengraph URL: https://github.com/nodejs/node
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fs: rmSync() reports UV_UNKNOWN with an empty code for unmapped errno values","articleBody":"### Version\nv26.7.0\n\n### Platform\nLinux x64\n\n### Subsystem\nfs / src/node_file.cc\n\n### What steps will reproduce the bug?\n\n```js\nconst fs = require('node:fs');\nfs.mkdirSync('a/b', { recursive: true });\ntry {\n fs.rmSync('a/.', { recursive: true, force: true });\n} catch (err) {\n console.log('code :', JSON.stringify(err.code));\n console.log('errno :', err.errno);\n console.log('syscall:', err.syscall);\n console.log('message:', err.message);\n}\n```\n\nOutput:\n\n```\ncode : \"\"\nerrno : -4094\nsyscall: \"rm\"\nmessage: , Unknown error: Invalid argument 'a/.'\n```\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`err.code` should be `'EINVAL'` and `err.errno` should be `-22`. The underlying\nfailure is a plain `EINVAL` from `rmdir(2)`, which POSIX requires for a path whose\nfinal component is `.`.\n\nEvery other `fs` error carries a usable `code`, and `err.code === 'EINVAL'` is the\ndocumented way to branch on `fs` failures, so an empty string breaks ordinary error\nhandling. The message is also malformed: it begins with `, ` because the empty code\nis interpolated into it.\n\n### What do you see instead?\n\n`errno` is `-4094` (`UV_UNKNOWN`) and `code` is the empty string.\n\n### Additional information\n\nThis is not specific to `EINVAL`. `RmSync()` in `src/node_file.cc` translates the\n`std::error_code` from `std::filesystem::remove_all()` with a hardcoded chain that\ncovers four values:\n\n* `operation_not_permitted` -> `EPERM`\n* `directory_not_empty` -> `ENOTEMPTY`\n* `not_a_directory` -> `ENOTDIR`\n* `permission_denied` -> `EACCES` (`EPERM` on Windows)\n\nAnything else falls through to the tail of the function:\n\n```c++\nstd::string message = \"Unknown error: \" + error.message();\nreturn env->ThrowErrnoException(\n UV_UNKNOWN, \"rm\", message.c_str(), path_c_str);\n```\n\nSo the mapping is an allowlist rather than a translation, and any errno outside\nthose four surfaces as `UV_UNKNOWN` with an empty `code`. `EINVAL` is simply the\none that is easiest to trigger from user code.\n\nThe async form is unaffected, because `fs.rm()` and `fsPromises.rm()` use the JS\n`rimraf` and report `EINVAL` correctly.\n\nNoting for context that the dot segment handling in #61958 is being addressed\nseparately at the JS layer. That change stops `a/.` from reaching this code path,\nbut it does not fix the mapping, which stays reachable for other errnos.\n","author":{"url":"https://github.com/AmarWaqar-TSKLI","@type":"Person","name":"AmarWaqar-TSKLI"},"datePublished":"2026-09-07T18:40:59Z","url":"https://github.com/nodejs/node/issues/65884"}
| 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 | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:2b89e7af-fdc4-d653-e6dc-ede3c902a9fd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D314:F5278:645397:84F813:6AED1DDB |
| html-safe-nonce | 7db8493577f39644d5b422785431c95d274b70b142a8bd6070e64befb8b76991 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzE0OkY1Mjc4OjY0NTM5Nzo4NEY4MTM6NkFFRDFEREIiLCJ2aXNpdG9yX2lkIjoiMzUwNDY4MTg0MzQ3MjI3Njk1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 977dab874f3985833845e0f1d2e190639ab5d06ab6f6a01c4197dab9ffd2970e |
| hovercard-subject-tag | repository:27193779 |
| 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/nodejs/node/issues/65884 |
| twitter:image | https://opengraph.githubassets.com/a874a8fae039dfe5591a0a677b494966333c58c16fee4133bc7d90ac365a0abf/nodejs/node |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a874a8fae039dfe5591a0a677b494966333c58c16fee4133bc7d90ac365a0abf/nodejs/node |
| og:image:alt | Node.js JavaScript runtime ✨🐢🚀✨. Contribute to nodejs/node development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e3e0f7f63e50c6fe879198a93a0a023a648ecc0a5e9bc3b5e033ac57172237e6 |
| turbo-cache-control | no-cache |
| 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 | 707a24b346ac8a82878b9c084efaa38a997660cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width