Skip to content

fix(adapter): add retry logic for redis psubscribe timeout#569

Open
anushka1822 wants to merge 1 commit intosocketio:mainfrom
anushka1822:fix/adapter-handshake-timeout
Open

fix(adapter): add retry logic for redis psubscribe timeout#569
anushka1822 wants to merge 1 commit intosocketio:mainfrom
anushka1822:fix/adapter-handshake-timeout

Conversation

@anushka1822
Copy link
Copy Markdown

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