UNPKG

@bitkyc08/opencodex

Version:

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code

17 lines (14 loc) • 710 B
import { retryWindowsFileOperation, transientWindowsReplaceCode } from "../lib/windows-atomic-replace"; /** A held Windows handle is contention, never owner-death evidence. */ export class LockFileBusy extends Error {} export function lockFileOperation<T>(operation: () => T, platform: NodeJS.Platform): T { let contended = false; try { return retryWindowsFileOperation({ run: operation, onRetry: () => { contended = true; } }, { platform, sleep: Bun.sleepSync }); } catch (error) { if (transientWindowsReplaceCode(platform, error) || (contended && (error as NodeJS.ErrnoException).code === "EEXIST")) throw new LockFileBusy("Lock filesystem operation is busy"); throw error; } }