Skip to content

feat: cache utilities + activeSessions reconnect fix - #4

Merged
kobie3717 merged 2 commits into
mainfrom
feat/cache-utilities
May 2, 2026
Merged

kobie3717 merged 2 commits into
mainfrom
feat/cache-utilities

Conversation

@kobie3717

Copy link
Copy Markdown
Owner

Summary

  • fix(reconnect): provider disconnected event now evicts the session from activeSessions, so consumer reconnect via createSession() no longer throws Session already exists on transient drops (Baileys reason -1, 515, 503). Reproduced live on whatshub-api: every closed: -1 was followed by repeated Connection failed: Error: Session ... already exists until container restart.
  • feat(utils): ExpiringMapCache + StoreCache (scavenged from openclaw) for downstream consumers.

Test plan

  • WaSP unit tests pass (npm test)
  • Build artifacts verified — dist/index.{js,mjs} contain new activeSessions.delete(sessionId) in disconnect handler
  • Confirm via whatshub-api logs over next 24h: no recurring "Session ... already exists" after WA drops; reconnect closes loop

🤖 Generated with Claude Code

root and others added 2 commits May 2, 2026 13:12
Provider 'disconnected' event left the session entry in activeSessions,
so consumer reconnect via createSession() threw "Session already exists"
and the connection stayed dropped until process restart.

Now remove the entry (and detach listeners) before re-emitting
SESSION_DISCONNECTED, so callers can recreate cleanly on transient drops
(Baileys reason -1, 515, 503).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kobie3717
kobie3717 merged commit a5aee72 into main May 2, 2026
2 checks passed
@kobie3717
kobie3717 deleted the feat/cache-utilities branch May 2, 2026 11:26
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