Created
June 3, 2018 20:33
-
-
Save koonuf/65242487f7534d96c2b7423fc7115f07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function removeDirWithRetries(folderPath) { | |
let delay = 50; | |
let attempts = 5; | |
const retryFunc = () => fsa.rmdirAsync(folderPath).catch((e) => { | |
if (e.code === "ENOTEMPTY") { | |
attempts--; | |
if (attempts > 0) { | |
return Promise.delay(delay *= 2).then(retryFunc); | |
} | |
} | |
throw e; | |
}); | |
return retryFunc(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment