Skip to content

fs: fix unhandled busy errors in RmSync#62611

Open
louiellan wants to merge 1 commit intonodejs:mainfrom
louiellan:fix-rmsync-unhandled-busy-err
Open

fs: fix unhandled busy errors in RmSync#62611
louiellan wants to merge 1 commit intonodejs:mainfrom
louiellan:fix-rmsync-unhandled-busy-err

Conversation

@louiellan
Copy link
Copy Markdown

@louiellan louiellan commented Apr 6, 2026

This fixes the unhandled busy errors in RmSync in the symlink_status call, because the allowed/retryable errors in RmSync could be thrown as early as symlink_status call, but it is only handled in the remove/remove_all calls and can only be retried from there. Without this, it bypasses the file_not_found check and recursive check in deleting a directory on ENFILE, EMFILE, EBUSY. It can also cause ENOTEMPTY error in the directory in a non-recursive option

This also fixes overridden errors that might happen in the symlink_status right before the remove/remove_all calls, that might mask the previous error

And this also fixes a subtle bug in the retryDelay because Sleep in Windows is already in ms units

Refs: #55555

This fixes the unhandled busy errors in rmSync in the symlink_status
call, because the allowed/retryable errors in rmSync could be thrown
as early as symlink_status call, but it is only handled in the
remove/remove_all calls and can only be retried from there

This also fixes overridden errors that might happen in the
symlink_status right before the remove/remove_all calls, that might
mask the true cause of the error happening in rmSync

Fixes: nodejs#55555
@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 Apr 6, 2026
@louiellan
Copy link
Copy Markdown
Author

As for the test validating this fix, I don't know if I should, since i searched all throughout the codebase, I didn't see any tests testing the retries with the busy errors (e.g., ENFILE, EMFILE), and if I did I might introduce a flaky test if I do a ulimit configuration

@louiellan
Copy link
Copy Markdown
Author

I don't know if this is also intentional with the sleep() on non-Windows platforms since it will definitely be 0 second given the condition that the retryDelay is less than 1000 (and by default it's 100, so up to some 10 retries before the retryDelay mechanism to take effect which is why I'm hesitating if this was intentional)

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.

2 participants