Documentation
    Preparing search index...

    A named lock that stays held until you release it, e.g. one workflow run holding a lock across several steps. For a single critical section, use the withLock() helper below instead.

    Index

    Constructors

    Methods

    • Acquire a lock that stays held until release() (or releaseAll()) is called. Re-entrant: acquiring a name already held by this MultiNodeMutex is a no-op.

      Parameters

      • name: string
      • opts: { timeoutMs?: number } = {}
        • OptionaltimeoutMs?: number

          throw if the lock isn't acquired within this many milliseconds. Defaults to DEFAULT_TIMEOUT_MS if not given.

      Returns Promise<void>

    • Release every lock still held. Call in a finally block around a run's execution so an error, finish, or pause never leaves a lock - and its dedicated connection - stuck open. One lock failing to release doesn't stop the rest from being attempted; any failures are thrown together once all locks have been tried.

      Returns Promise<void>

    • Run fn() while holding an exclusive lock named name, released as soon as fn() returns or throws.

      Type Parameters

      • T

      Parameters

      • name: string

        lock name; shared names are mutually exclusive across nodes

      • fn: () => Promise<T>

        critical section to run while the lock is held

      • opts: { timeoutMs?: number } = {}
        • OptionaltimeoutMs?: number

          see acquire()

      Returns Promise<T>