Skip to content

feat: emit a "session-expiry" event when a session has expired#5478

Open
976520 wants to merge 1 commit intosocketio:mainfrom
976520:feat/session-expiry-event
Open

feat: emit a "session-expiry" event when a session has expired#5478
976520 wants to merge 1 commit intosocketio:mainfrom
976520:feat/session-expiry-event

Conversation

@976520
Copy link

@976520 976520 commented Mar 19, 2026

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

When a session expires and is removed in SessionAwareAdapter, no event is emitted, making it impossible for external consumers to detect when a session has expired.

New behavior

SessionAwareAdapter now emits a "session-expiry" event whenever an expired session is deleted. The event handler receives the sid of the expired session as an argument.

Other information (e.g. related issues)

#5250

@darrachequesne
Copy link
Member

Hi! Thanks for the pull request.

Could you please explain your use case for this feature?

@976520
Copy link
Author

976520 commented Mar 19, 2026

@darrachequesne

Sure!! When using connection state recovery, there's currently no way to know when a persisted session has expired. This makes it difficult to perform cleanup logic tied to session lifetime

e.g.

  • Updating a user's online/presence status when their session can no longer be recovered
  • Cleaning up server side resources like cached user data that were kept alive in anticipation of reconnection
  • Logging or analytics around session recovery failures

Without this event, the only option is to poll or rely on external timeouts, which are harder to synchronize with the actual expiry logic inside SessionAwareAdapter.

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.

2 participants