Repository navigation
fix(postgres-emitter): include the namespace in published messages - #5601
Open
ricardoasmarques wants to merge 1 commit into
Open
ricardoasmarques wants to merge 1 commit into
ricardoasmarques wants to merge 1 commit into
Conversation
Since version 0.4.0, `@socket.io/postgres-adapter` extends the
`ClusterAdapter` class, which ignores any message whose top-level `nsp`
does not match its namespace. The emitter only set `nsp` on the inner
packet, so every message it published was dropped ("ignore message from
another namespace (undefined)").
The tests now run against `@socket.io/postgres-adapter@0.5.0` instead of
`0.1.x`, which did not check the namespace and hid the issue.
Co-authored-by: Cursor <cursoragent@cursor.com>
ricardoasmarques
marked this pull request as ready for review
November 12, 2026 15:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The kind of change this PR does introduce
Current behavior
With
@socket.io/postgres-emitter@0.1.1and@socket.io/postgres-adapter@0.4.0or later, the servers never receive anything the emitter publishes.Since 0.4.0, the Postgres adapter extends
ClusterAdapterfromsocket.io-adapter, which drops messages whose top-levelnspdoesn't match:0.5.0 also routes incoming messages by
msg.nsp(namespaces.get(msg.nsp)) before reaching that check.The emitter sets
nsponly on the inner packet (data.packet.nsp), never on the message itself. So every broadcast,socketsJoin/socketsLeave,disconnectSocketsandserverSideEmitis dropped, with this debug log on each server:The emitter's tests didn't catch it because the root
package.jsonpins@socket.io/postgres-adapterto^0.1.0, which never checked the namespace.New behavior
publish()setsdocument.nsp = this.emitter.nspnext todocument.uid. Every message goes throughpublish(), so this covers both the directpg_notifypath and the attachment path (payload overpayloadThreshold, or with binary data).The dev dependency moves to
@socket.io/postgres-adapter@^0.5.0, so the existing tests now run against a current adapter. Locally with Postgres 14 (as in CI):0.5.0without the fix: the broadcast tests time out0.5.0with the fix: 12 passingOther information (e.g. related issues)
I couldn't find an existing issue. We hit this in production after moving an emit-only worker from the full adapter to the emitter: the worker's events stopped reaching clients without any error.