eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 523 B
JavaScript
import{rename}from"node:fs/promises";import{isErrnoCode}from"#shared/guards.js";const TRANSIENT_RENAME_RETRY_DELAYS_MS=[10,20,40,80,160,320,640];async function renameWithTransientBusyRetry(t,n){for(let r of TRANSIENT_RENAME_RETRY_DELAYS_MS)try{await rename(t,n);return}catch(e){if(!isTransientRenameError(e))throw e;await new Promise(e=>setTimeout(e,r))}await rename(t,n)}function isTransientRenameError(e){return isErrnoCode(e,`EPERM`)||isErrnoCode(e,`EACCES`)||isErrnoCode(e,`EBUSY`)}export{renameWithTransientBusyRetry};