Repository navigation
fix: use the JSON message replacer for automatic pongs - #703
Merged
enisdenjo merged 1 commit intoOct 15, 2026
Merged
Conversation
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.
Both the client and the server answer a
pingwith apongthat echoes the ping's payload, but that pong is the only message they serialize withoutjsonMessageReplacer. Every other message (connection_init,connection_ack,subscribe,next,error,complete) already passes it.This matters when the reviver and replacer are a pair. For example, with a reviver that turns a field into a
BigIntand a replacer that turns it back into a string, the revived ping payload can't be serialized for the pong:JSON.stringifythrows "Do not know how to serialize a BigInt", and the connection gets closed.The fix passes
replacertostringifyMessagefor the automatic pong insrc/server.tsandsrc/client.ts.Tests: one new test in
tests/server.test.tsand one intests/client.test.ts, each sending a ping with a payload that the reviver turns into aBigInt. Both fail onmaster(the server test gets no pong, and the client closes the socket) and pass with this change. The full suite,tsc --noEmitand Prettier pass. A patch changeset is included.