Skip to content

fix(adapter): do not skip local broadcast when publishAndReturnOffset throws#5457

Merged
darrachequesne merged 1 commit into
socketio:mainfrom
Not-Sarthak:fix/cluster-adapter-broadcast-error-handling
Mar 12, 2026
Merged

fix(adapter): do not skip local broadcast when publishAndReturnOffset throws#5457
darrachequesne merged 1 commit into
socketio:mainfrom
Not-Sarthak:fix/cluster-adapter-broadcast-error-handling

Conversation

@Not-Sarthak

Copy link
Copy Markdown
Contributor

Summary

Fixes #5456

In ClusterAdapter.broadcast(), the catch block used return debug(...) which prevented super.broadcast(packet, opts) from ever being called when publishAndReturnOffset() rejected. This meant sockets connected to the same server instance that emitted the event would silently never receive it.

The fix removes the return keyword so that super.broadcast() is still called after logging the error — matching the pattern already used in addSockets, delSockets, and disconnectSockets.

  • Before: remote publish error → return debug(...)super.broadcast() skipped → local sockets get nothing
  • After: remote publish error → debug(...)super.broadcast() still runs → local sockets receive the event

Test plan

  • Added test case: "broadcasts to local clients even when publishAndReturnOffset throws"
  • All 48 existing adapter tests still pass
  • engine.io tests pass (189/189)
  • engine.io-client tests pass (93/93)

… throws

Remove the `return` in the catch block of ClusterAdapter.broadcast() so
that super.broadcast() is still called when remote publishing fails.
This ensures local sockets receive the event even if the cluster publish
errors out (e.g. due to a serialization error in the adapter layer).

Fixes #5456
@darrachequesne darrachequesne merged commit f630158 into socketio:main Mar 12, 2026
@darrachequesne

Copy link
Copy Markdown
Member

Thanks 👍

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.

ClusterAdapter.broadcast() silently drops events to local sockets when publishAndReturnOffset throws error

2 participants