Skip to content

Conversation

@anushka1822
Copy link

Problem

In distributed environments, the Redis handshake can fail due to temporary network timeouts, causing the adapter to crash on initialization.

Solution

Implemented a retry mechanism with exponential backoff for the psubscribe call (and pSubscribe for Redis v4).

  • Max Retries: 3
  • Backoff: 100ms, 200ms, 300ms.
  • Failover: Emits an 'error' event after 3 failed attempts instead of crashing.

Changes

  1. lib/index.ts: Added withRetry helper method and wrapped subscription logic.
  2. test/adapter-retries.ts: Added unit tests using Mocha/Sinon to verify retry counts.
  3. tsconfig.json: Updated to include test/**/* and enabled esModuleInterop for testing compatibility.

Verification

Tests pass locally:

  • ✔ should retry psubscribe call
  • ✔ should retry pSubscribe call (Redis v4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant