UNPKG

syncguard

Version:

Functional TypeScript library for distributed locking across microservices. Prevents race conditions with Redis, PostgreSQL, Firestore, and custom backends. Features automatic lock management, timeout handling, and extensible architecture.

30 lines (29 loc) 1.23 kB
import { LockError } from "../common/backend.js"; /** * Internal error type used to signal non-retryable abort from within Firestore transactions. * When thrown inside a transaction callback, Firestore will not retry the transaction. * This prevents infinite retry loops when AbortSignal is triggered. * * @internal Used only within Firestore operation implementations */ export declare class FirestoreAbortError extends Error { readonly __firestoreAbortMarker = true; constructor(message?: string); } /** * Checks if an AbortSignal has been aborted and throws FirestoreAbortError if so. * Use this inside Firestore transaction callbacks to prevent automatic retries. * * @param signal - Optional AbortSignal to check * @throws FirestoreAbortError if signal is aborted (non-retryable by Firestore) * @internal Used by Firestore operation implementations */ export declare function checkAbortedForTransaction(signal?: AbortSignal): void; /** * Maps Firestore SDK errors to standardized LockError codes. * * @param error - Firestore SDK error or string * @returns LockError with appropriate code and context * @see docs/specs/interface.md */ export declare function mapFirestoreError(error: any): LockError;