Skip to content

Fix event dispatch before disconnection - #5531

Open
mjibulu wants to merge 1 commit into
socketio:mainfrom
mjibulu:fix/5213-disconnect-event-order
Open

Fix event dispatch before disconnection#5531
mjibulu wants to merge 1 commit into
socketio:mainfrom
mjibulu:fix/5213-disconnect-event-order

Conversation

@mjibulu

@mjibulu mjibulu commented Aug 1, 2026

Copy link
Copy Markdown

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 complete non-binary event is received before disconnection, onAny() can observe it while the named listener is skipped because dispatch is deferred until after the socket's connection state changes.

New behavior

Complete non-binary events whose middleware completes synchronously are dispatched immediately while the socket is connected. Asynchronous middleware, events received after disconnection, and binary events retain their existing deferred and guarded behavior.

Other information (e.g. related issues)

Fixes #5213

The existing binary-packet regression test associated with #3095 remains unchanged and passes.

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.

Events before disconnection dropped

1 participant