Skip to content

fix(postgres-emitter): keep the options of the emitter in of() - #5647

Open
rafay247 wants to merge 1 commit into
socketio:mainfrom
rafay247:fix/postgres-emitter-of-options
Open

rafay247 wants to merge 1 commit into
socketio:mainfrom
rafay247:fix/postgres-emitter-of-options

Conversation

@rafay247

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

Emitter.of() in @socket.io/postgres-emitter creates the new emitter without the options of the current one:

const emitter = new Emitter(pool, "/", { channelPrefix: "my-app" });

emitter.of("/admin").channel; // "socket.io#/admin" instead of "my-app#/admin"

So channelPrefix, tableName and payloadThreshold go back to their defaults for any namespace other than the main one. With a custom channelPrefix, the servers listen on my-app#/admin and never receive what emitter.of("/admin") publishes. With a custom tableName, large or binary payloads are inserted into socket_io_attachments instead.

New behavior

The emitter keeps its options, and of() passes them to the new emitter, like of() in @socket.io/redis-streams-emitter does.

Other information (e.g. related issues)

Added a test that creates an emitter with all three options and checks them on emitter.of("/custom"). It fails without the change (expected 'socket.io#/custom' to sort of equal 'custom-prefix#/custom'). All 13 tests pass with Postgres 14, and npm run format:check passes.

This does not overlap with #5570 / #5601, which add the top-level nsp to published messages.

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