Title: fs.opendir() and fs.promises.opendir() crash the process on an invalid bufferSize · Issue #67182 · nodejs/node · GitHub
Open Graph Title: fs.opendir() and fs.promises.opendir() crash the process on an invalid bufferSize · Issue #67182 · nodejs/node
X Title: fs.opendir() and fs.promises.opendir() crash the process on an invalid bufferSize · Issue #67182 · nodejs/node
Description: Version v28.0.0-pre (main at 95f3cf0), also v22.20.0 and v20.20.2 Platform Linux 7.0.0-38-generic x86_64 Subsystem fs What steps will reproduce the bug? const fs = require('node:fs'); (async () => { try { await fs.promises.opendir(__dirn...
Open Graph Description: Version v28.0.0-pre (main at 95f3cf0), also v22.20.0 and v20.20.2 Platform Linux 7.0.0-38-generic x86_64 Subsystem fs What steps will reproduce the bug? const fs = require('node:fs'); (async () => ...
X Description: Version v28.0.0-pre (main at 95f3cf0), also v22.20.0 and v20.20.2 Platform Linux 7.0.0-38-generic x86_64 Subsystem fs What steps will reproduce the bug? const fs = require('node:fs'); (asyn...
Opengraph URL: https://github.com/nodejs/node/issues/67182
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fs.opendir() and fs.promises.opendir() crash the process on an invalid bufferSize","articleBody":"### Version\n\nv28.0.0-pre (main at 95f3cf07), also v22.20.0 and v20.20.2\n\n### Platform\n\n```text\nLinux 7.0.0-38-generic x86_64\n```\n\n### Subsystem\n\nfs\n\n### What steps will reproduce the bug?\n\n```js\nconst fs = require('node:fs');\n\n(async () => {\n try {\n await fs.promises.opendir(__dirname, { bufferSize: 0 });\n } catch (err) {\n console.log('caught', err.code);\n }\n console.log('still running');\n})();\n```\n\nThe callback form behaves the same:\n\n```js\ntry {\n fs.opendir(__dirname, { bufferSize: 0 }, (err) => console.log('callback', err));\n} catch (err) {\n console.log('caught', err.code);\n}\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways, with any invalid `bufferSize` (`0`, `-1`, `1.5`, `NaN`, `'1'`, `null`, ...).\n\n### What is the expected behavior? Why is that the expected behavior?\n\nThe error reaches the caller: `fs.opendir()` throws (as `fs.readdir()` and `fs.writeFile()` do for invalid options), and `fs.promises.opendir()` rejects. `fs.opendirSync()` already throws a catchable error.\n\n### What do you see instead?\n\nNeither `catch` runs, the callback is never called, and the process exits with code 1:\n\n```text\nRangeError [ERR_OUT_OF_RANGE]: The value of \"options.bufferSize\" is out of range. It must be >= 1 && \u003c= 4294967295. Received 0\n at new Dir (node:internal/fs/dir:64:7)\n at FSReqCallback.opendirCallback [as oncomplete] (node:internal/fs/dir:357:22)\n```\n\n### Additional information\n\n`bufferSize` is only validated in the `Dir` constructor, which `fs.opendir()` calls from the completion callback of the native call, so the error is thrown outside the caller's code. The handle is closed before the throw, so nothing leaks. I have a fix and will open a PR.\n","author":{"url":"https://github.com/yohannesjoya","@type":"Person","name":"yohannesjoya"},"datePublished":"2026-11-01T11:59:35Z","url":"https://github.com/nodejs/node/issues/67182"}
| 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:5794b8aa-b23c-9e83-4e26-c57867cdd270 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EC10:26CE3B:ED741C:147F5F4:6AFBF514 |
| html-safe-nonce | aceefae3c0e01966d954da7180a69bd8925a09a0015f9a9186dab7dc987ada65 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzEwOjI2Q0UzQjpFRDc0MUM6MTQ3RjVGNDo2QUZCRjUxNCIsInZpc2l0b3JfaWQiOiIxNTc3NTQzNzQ0NDczNTI3NTcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 873aae779c10af521e3bc767adcd1aa977a784d41b1dd5772901cb1655d940e5 |
| hovercard-subject-tag | issue:6146611241 |
| 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/67182/issue_layout |
| twitter:image | https://opengraph.githubassets.com/93244b12918fd8c9490ddc9701826a109acf6498d11068f5272bc07079ef23c6/nodejs/node/issues/67182 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/93244b12918fd8c9490ddc9701826a109acf6498d11068f5272bc07079ef23c6/nodejs/node/issues/67182 |
| og:image:alt | Version v28.0.0-pre (main at 95f3cf0), also v22.20.0 and v20.20.2 Platform Linux 7.0.0-38-generic x86_64 Subsystem fs What steps will reproduce the bug? const fs = require('node:fs'); (async () => ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yohannesjoya |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| 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 | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width