Skip to content

feat(sockets): message delivery guarantees + offline queue - #300

Merged
Tybravo merged 1 commit into
SwiftChainn:mainfrom
ayo-mide55:fix/issue-147
Oct 4, 2026
Merged

Tybravo merged 1 commit into
SwiftChainn:mainfrom
ayo-mide55:fix/issue-147

Conversation

@ayo-mide55

Copy link
Copy Markdown
Contributor

Closes #147

Adds at-least-once delivery guarantees for driver-bound socket messages in src/sockets/messageQueue.ts:

  • ACK gating — an ACK-required message is retained until the client acks it (empty object counts as an ack); no ack ⇒ re-delivery on timeout up to a bounded retry budget.
  • Bounded queue — per-driver bound (SOCKET_MESSAGE_QUEUE_MAX, default 100) with oldest-first eviction.
  • Retry budget — SOCKET_MESSAGE_MAX_RETRIES (default 5) automatic re-deliveries after ACK timeouts; exhausted messages stay queued for the next reconnect flush.
  • Idempotent flush on reconnect — flush() re-delivers each unacked message exactly once, so a reconnecting driver never gets duplicates.
  • Per-driver isolation and safe disconnect handling.

New env knobs documented in .env.example/src/config/env.ts (validated). socket.service.ts wired to the new callbacks.

Tests: tests/messageQueue.test.ts — 17 pass (queued until ACK, ACK removal, reconnect flush without duplicates, ACK-timeout retry, queue bound/eviction, per-driver isolation).

Run: npx jest tests/messageQueue.test.ts --runInBand --forceExit.

@Tybravo

Tybravo commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

@ayo-mide55

Thank you for contributing to the project

@Tybravo
Tybravo merged commit 3bd5a3f into SwiftChainn:main Oct 4, 2026
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.

[Enhancement] Implement WebSocket message delivery guarantees and an offline message queue

2 participants