Repository navigation
fix: [node-core-library] Retry transient Windows EPERM/EBUSY in FileSystem.deleteFolder(Async) - #5836
Conversation
|
Ian Clanton-Thuon (@iclanton) any chance this could get a review? |
|
(FWIW: Although we're at the same company, I did independently encounter and come up with basically the same solution as Bart did, just on a different repo. Without the fix, a very basic one-line TS "hello world" with just TS+heft as the main dependencies will hit the EPERM issue maybe about a quarter of the time, simply from |
…ystem.deleteFolder(Async)
… FileSystem.ensureEmptyFolderAsync
81fd31f to
a8b1085
Compare
|
Pete Gonzalez (@octogonz) Apostolis Haitalis (@apostolisms) David Michon (@dmichon-msft) Jonathon Anthony (@jxanthony) Bharat Middha (@bmiddha) Ian Clanton-Thuon (@iclanton) the branch has been rebased onto the latest |
|
Bart van den Ende (@bartvandenende-wm) Ian Clanton-Thuon (@iclanton) this got merged before I finished reviewing it. See my notes here: #6230 |
Summary
Restores retry-on-transient-error behavior to
FileSystem.deleteFolderandFileSystem.deleteFolderAsyncon Windows, fixingEPERM: operation not permitted, rmdirfailures duringrush rebuild/ HeftcleanFileson self-hosted Windows runners.Fixes #5373.
Details
Root cause
In v5.11.0 (PR #5088)
node-core-librarybumped itsfs-extradependency from~7.0.1to~11.3.0.fs-extra.remove(Sync)was backed byrimraf@2, which retriesEBUSY/EPERM/ENOTEMPTYon Windows by default (maxBusyTries: 3).fs-extra@10onward,remove(Sync)is a thin wrapper aroundfs.rm(path, { recursive: true, force: true })with no retry options.The retry behavior was silently lost, which made consumers susceptible to the documented Windows transient where another process briefly holds a handle to a child of the directory being removed.
Change
Replace the two affected methods with native
fs.rmSync/fsPromises.rmusing{ recursive: true, force: true, maxRetries: 3, retryDelay: 100 }.fs-extra@11'sremove(Sync)is already a thin wrapper over the same native call.Note
I also added
ensureEmptyFolder/ensureEmptyFolderAsyncfor consistency as they exhibit the same regression.How it was tested
manual testing