Title: `fs.promises.rm` recursive on a huge directory-tree with missing permissions can result in OOM · Issue #56433 · nodejs/node · GitHub
Open Graph Title: `fs.promises.rm` recursive on a huge directory-tree with missing permissions can result in OOM · Issue #56433 · nodejs/node
X Title: `fs.promises.rm` recursive on a huge directory-tree with missing permissions can result in OOM · Issue #56433 · nodejs/node
Description: Version 22.11.0 Platform Microsoft Windows NT 10.0.22631.0 x64 Subsystem FS What steps will reproduce the bug? While trying to delete a folder without permissions to delete the content of the folder fs.rm takes huge amounts of RAM with p...
Open Graph Description: Version 22.11.0 Platform Microsoft Windows NT 10.0.22631.0 x64 Subsystem FS What steps will reproduce the bug? While trying to delete a folder without permissions to delete the content of the folde...
X Description: Version 22.11.0 Platform Microsoft Windows NT 10.0.22631.0 x64 Subsystem FS What steps will reproduce the bug? While trying to delete a folder without permissions to delete the content of the folde...
Opengraph URL: https://github.com/nodejs/node/issues/56433
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`fs.promises.rm` recursive on a huge directory-tree with missing permissions can result in OOM","articleBody":"### Version\n\n22.11.0\n\n### Platform\n\n```text\nMicrosoft Windows NT 10.0.22631.0 x64\n```\n\n### Subsystem\n\nFS\n\n### What steps will reproduce the bug?\n\nWhile trying to delete a folder without permissions to delete the content of the folder fs.rm takes huge amounts of RAM with potential OOM-Exceptions down the road.\n\nSteps to reproduce:\n1) Create a complex folder tree (see following script as an example)\n2) Ensure user that executes fs.rm has permission to delete rootfolder but does not have permissions to delete content of the rootfolder.\n3) Execute Deletion Script\n\nThe testscript did not result in an OOM-exception for me (it stopped at ~8gb RAM usage). You can just create more files to run into an OOM eventually (it broke in production with an OOM for us).\n\nCreate data folder:\n```\nimport { randomUUID } from \"crypto\";\nimport { mkdir, writeFile } from \"fs/promises\";\nimport { userInfo } from \"os\";\nimport { join } from \"path\";\n\nconst parentPath = \"D:\\\\testData\\\\permission\";\n\nfor (let i = 0; i \u003c 1_000_000; i++) {\n const uuid = randomUUID();\n const folderPath = join(parentPath, uuid.slice(0, 2), uuid.slice(2, 4), uuid);\n await mkdir(folderPath, {recursive: true, mode: 744});\n await writeFile(join(folderPath, \"first\"), \"1\", {mode: 744});\n await writeFile(join(folderPath, \"second\"), \"1\", {mode: 744});\n await writeFile(join(folderPath, \"third\"), \"1\", {mode: 744});\n}\n```\n\nExecuting Deletion:\n```\nimport { rm } from \"fs/promises\";\nconst parentPath = \"D:\\\\testData\\\\permission\";\n\nawait rm(parentPath, {recursive: true});\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAs long as enough files/folders are in the to be deleted folder and corresponding permission issues exists the bug reproduces.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nTrying to delete a folder should not result in an OOM. Here: it should fail because of permission issues.\n\n### What do you see instead?\n\nHuge memory consumption until OOM eventually (with enough content in the folder)\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/viyaha","@type":"Person","name":"viyaha"},"datePublished":"2025-01-02T13:02:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/56433/node/issues/56433"}
| 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:d1102887-6c7b-4d4b-3322-81886aadd9dc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A2D6:254982:1569BFA:1D22F26:6A4C7F94 |
| html-safe-nonce | 5fe15cab8c989c1dc6469da67d82fe3874b910b4a8690034827d34fd06a737c7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkQ2OjI1NDk4MjoxNTY5QkZBOjFEMjJGMjY6NkE0QzdGOTQiLCJ2aXNpdG9yX2lkIjoiNzAxNDM5NTY0MzA1NDI5Mjg4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4a527a9bce9615ed1aecdba63207fc9382ccf83e999a5b9f4d096e66f39f204b |
| hovercard-subject-tag | issue:2765998313 |
| 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/56433/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d908081b84b7a54e75f1f7859a3a2a0b02c8f74b98566ab63dc4943b305161fe/nodejs/node/issues/56433 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d908081b84b7a54e75f1f7859a3a2a0b02c8f74b98566ab63dc4943b305161fe/nodejs/node/issues/56433 |
| og:image:alt | Version 22.11.0 Platform Microsoft Windows NT 10.0.22631.0 x64 Subsystem FS What steps will reproduce the bug? While trying to delete a folder without permissions to delete the content of the folde... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | viyaha |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| 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 | cd470457e909b9d062f8002cf438ba870e6acff6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width