Allow JSON request payload for RSocket #256
Merged
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.
With the ongoing work to move more parts of the sync logic into the core extension, client SDKs no longer need to implement the BSON deserialization logic themselves (instead relying on our Rust decoder to take care of that). But while that covers response handing, clients are still responsible for crafting RSocket requests (e.g. to transmit tokens or a user agent).
At the moment, our code to handle RSocket requests always assumes that the connection data and metadata will be encoded as BSON. This is unfortunate for clients, because they then need to ship a BSON encoder for the sole purpose of creating these tiny request payloads (and especially on JavaScript, our dependency on the BSON library requires special compilation support for
@powersync/common). So while we continue to serve BSON only for RSocket requests, we should look for ways to get rid of BSON support on the client SDKs.The RSocket protocol has space for two mime types for metadata and data fields as part of the
SETUPframe, and the JavaScript SDK correctly sets those toapplication/bson. To support other clients without a BSON library in the future, this changes the sync service to also accept requests with anapplication/jsoncontent type. This allows e.g. the Kotlin SDK to adopt the RSocket protocol.