Skip to content
Discussion options

You must be logged in to vote

Hi @msalafia, sorry for the very slow reply!

You're right: in the current version (0.8.9), retryDelay only takes a number, and the lock waits that same fixed delay between attempts. For now, you can get backoff by turning the built-in retries off (retryAttempts: 0) and retrying in a small helper:

import { setTimeout as sleep } from 'node:timers/promises';
import { LockAcquisitionError, type ExtendedAbortSignal, type Lock } from 'redlock-universal';

/**
 * lock.using() with exponential backoff and full jitter between attempts.
 * Create the lock with retryAttempts: 0 so that only this helper retries.
 */
export async function usingWithBackoff<T>(
  lock: Lock,
  routine: (signal: Extended…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by alexpota
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants