Skip to content

fs: treat std::errc::permission_denied as EPERM error#64017

Open
louiellan wants to merge 1 commit into
nodejs:mainfrom
louiellan:permission-denied-as-eperm
Open

fs: treat std::errc::permission_denied as EPERM error#64017
louiellan wants to merge 1 commit into
nodejs:mainfrom
louiellan:permission-denied-as-eperm

Conversation

@louiellan

Copy link
Copy Markdown

Fixes #64016

In the thrown exception, std::errc::permission_denied is already treated as an EPERM error, but it is not included in one of the omittable errors when retrying the RmSync operation. This commit includes it.

This also fixes the retryDelay calculation on Windows where the retryDelay is divided by 1000 but the win32's Sleep function takes the argument as an ms unit, dividing the supplied ms unit further to a much smaller delay.

I tried writing a test for this fix but node doesn't do file lock when opening a file, even if it's ran as another process, and running python as a child process in the test file yields race conditions (i.e., python does create the folder and the file to be locked but the js test fails because it can't do a rmSync because the file and the folder does not exist)

But I validated the reproducible steps mentioned in the issue with this fix, the rmSync now delays the retries and is around 15000ms, the same as the asynchronous fs.rm

In the thrown exception, `std::errc::permission_denied` is already
treated as an `EPERM` error, but it is not included in one of the
omittable errors when retrying the `RmSync` operation. This commit
includes it.

This also fixes the `retryDelay` calculation on Windows where the
`retryDelay` is divided by `1000` but the win32's `Sleep` function
takes the argument as an `ms` unit, dividing the supplied `ms` unit
further to a much smaller delay.

Signed-off-by: louiellan <louie.lou.llaneta@gmail.com>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent retryDelay in fs.rmSync and asynchronous fs.rm (on Windows)

2 participants