Title: fs: do not treat EPERM as ENOTEMPTY on Windows by PickBas · Pull Request #63709 · nodejs/node · GitHub
Open Graph Title: fs: do not treat EPERM as ENOTEMPTY on Windows by PickBas · Pull Request #63709 · nodejs/node
X Title: fs: do not treat EPERM as ENOTEMPTY on Windows by PickBas · Pull Request #63709 · nodejs/node
Description: Changes fs.rm(..., { recursive: true }) on Windows treats EPERM from rmdir as "directory not empty" and recurses into children. That's wrong, because on Windows, EPERM means "no permission to delete", not "still has contents". Windows now uses its own notEmptyErrorCodes set that excludes EPERM. Safety The EPERM treatment as non-empty traces to rimraf 2.2: (changelog, commit): As per http://sourceforge.net/mailarchive/message.php?msg_id=31240176 sshfs-mounted directories return EPERM on rmdir called with non-empty dir. Hence removing non-empty directories mounted through sshfs didn't work with rimraf, and this change makes it work. This does not apply to Windows, so EPERM is safely removed from notEmptyErrorCodes and is kept for other platforms. Before/After JS Script used as rm.js: import { rmSync } from "fs"; import { rm } from "fs/promises"; const parentPath = "C:\\Users\\dev\\permissions\\folders"; await rm(parentPath, {recursive: true}); Before PS C:\Users\dev\permissions> node.exe --max-old-space-size=30 .\rm.js <--- Last few GCs ---> .6[25312:000001C3A99BC000] 515 ms: Mark-Compact 24.7 (87.4) -> 23.3 (89.4) MB, pooled: 0 MB, 2.46 / 0.00 ms (+ 1.4 ms in 71 steps since start of marking, biggest step 0.1 ms, walltime since start of marking 9 ms) (average mu = 0.736, current mu = 0.70[25312:000001C3A99BC000] 592 ms: Mark-Compact 38.7 (89.4) -> 30.8 (96.4) MB, pooled: 0 MB, 10.28 / 0.00 ms (+ 0.8 ms in 66 steps since start of marking, biggest step 0.2 ms, walltime since start of marking 20 ms) (average mu = 0.833, current mu = 0. FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory After PS C:\Users\dev\permissions> ..\node_projects\node\Release\node.exe --max-old-space-size=30 .\rm.js node:internal/modules/run_main:107 triggerUncaughtException( ^ [Error: EPERM: operation not permitted, rmdir 'C:\Users\kirill\dev\permissions\folders\00'] { errno: -4048, code: 'EPERM', syscall: 'rmdir', path: 'C:\\Users\\dev\\permissions\\folders\\00' } Node.js v27.0.0-pre Fixes: #56433
Open Graph Description: Changes fs.rm(..., { recursive: true }) on Windows treats EPERM from rmdir as "directory not empty" and recurses into children. That's wrong, because on Windows, EPERM means "no ...
X Description: Changes fs.rm(..., { recursive: true }) on Windows treats EPERM from rmdir as "directory not empty" and recurses into children. That's wrong, because on Windows, EPERM mea...
Opengraph URL: https://github.com/nodejs/node/pull/63709
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:ff9c4e80-55f7-8050-f4f0-2334a4b2be1c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E35E:2F0FC4:64CB7B:8895E5:6A4C7CE1 |
| html-safe-nonce | 9349bdd5f3113d44323e3ccb4a90495da12dc7cedf65cfc1cff741b258e08402 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzVFOjJGMEZDNDo2NENCN0I6ODg5NUU1OjZBNEM3Q0UxIiwidmlzaXRvcl9pZCI6IjU2MzgzNjA1Njg5MjQyNDExMjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | aa742f53ee3f9ce135a140f13df1b9b00ca3d24842f7eb74a515cbfd3daf2398 |
| hovercard-subject-tag | pull_request:3787715580 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/pull/63709/files |
| twitter:image | https://avatars.githubusercontent.com/u/38224153?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/38224153?s=400&v=4 |
| og:image:alt | Changes fs.rm(..., { recursive: true }) on Windows treats EPERM from rmdir as "directory not empty" and recurses into children. That's wrong, because on Windows, EPERM means "no ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| 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