@yorkie-js/sdk
    Preparing search index...

    Interface SessionLock

    SessionLock is a pluggable, single-active-session guard used by the offline persistence path. Offline persistence derives a stable actor from the app's clientKey, so two browser tabs of the same app+user share that actor. Two live tabs would then share one server checkpoint and mint colliding clientSeq values — silent edit loss. The guard elects a single active session per document key so the second tab fails fast instead of corrupting the store.

    The abstraction is injectable so it can be tested without a real browser: the default WebLocksSessionLock is backed by the Web Locks API, and tests pass an in-memory fake.

    interface SessionLock {
        acquire(name: string): Promise<SessionLockHandle | undefined>;
    }

    Implemented by

    Index

    Methods

    Methods

    • acquire tries to acquire the lock named name without waiting. It resolves with a SessionLockHandle when the lock was acquired, or undefined when it is already held elsewhere (e.g. by another tab) — the caller treats undefined as fail-fast.

      Parameters

      • name: string

      Returns Promise<SessionLockHandle | undefined>