From 7dfb853c3377e7f774100ee0aff6f26f83640d13 Mon Sep 17 00:00:00 2001 From: louiellan Date: Sat, 20 Jun 2026 08:49:59 +0800 Subject: [PATCH] fs: treat `std::errc::permission_denied` as `EPERM` error 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 --- src/node_file.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node_file.cc b/src/node_file.cc index d93f213202ec43..2bbe9fa9a36a31 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1785,6 +1785,9 @@ static void RmSync(const FunctionCallbackInfo& args) { error == std::errc::too_many_files_open || error == std::errc::too_many_files_open_in_system || error == std::errc::directory_not_empty || + #ifdef _WIN32 + error == std::errc::permission_denied || + #endif error == std::errc::operation_not_permitted); }; @@ -1805,7 +1808,7 @@ static void RmSync(const FunctionCallbackInfo& args) { if (retryDelay > 0) { #ifdef _WIN32 - Sleep(i * retryDelay / 1000); + Sleep(i * retryDelay); #else sleep(i * retryDelay / 1000); #endif