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(e,t){for(let n of TRANSIENT_RENAME_RETRY_DELAYS_MS)try{await rename(e,t);return}catch(e){if(!isTransientRenameError(e))throw e;await new Promise(e=>setTimeout(e,n))}await rename(e,t)}function isTransientRenameError(e){return isErrnoCode(e,`EPERM`)||isErrnoCode(e,`EACCES`)||isErrnoCode(e,`EBUSY`)}export{renameWithTransientBusyRetry};