@karmaniverous/jeeves
    Preparing search index...

    Function withFileLock

    • Execute a callback while holding an exclusive lock on a file.

      Parameters

      • filePath: string

        Absolute path to the file to lock.

      • fn: () => void | Promise<void>

        Callback to execute while holding the lock.

      • staleMs: number = STALE_LOCK_MS

        Stale threshold in ms. Defaults to STALE_LOCK_MS.

      Returns Promise<void>

      Fails fast (no retries) with an ELOCKED error when the lock is held, matching the v0.x behaviour. The lock is always released in a finally block. The target file need not exist. fn must complete well within staleMs: the lock is not refreshed while held, so a longer callback can be taken over by another process.