Skip to content

Conversation

@simolus3
Copy link
Contributor

@simolus3 simolus3 commented May 6, 2025

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 SETUP frame, and the JavaScript SDK correctly sets those to application/bson. To support other clients without a BSON library in the future, this changes the sync service to also accept requests with an application/json content type. This allows e.g. the Kotlin SDK to adopt the RSocket protocol.

@changeset-bot
Copy link

changeset-bot bot commented May 6, 2025

🦋 Changeset detected

Latest commit: a602fb2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@powersync/service-image Minor
@powersync/service-rsocket-router Patch
@powersync/service-errors Patch
@powersync/service-core Minor
@powersync/lib-services-framework Patch
@powersync/service-core-tests Patch
@powersync/service-module-mongodb-storage Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres-storage Patch
@powersync/service-module-postgres Patch
test-client Patch
@powersync/lib-service-mongodb Patch
@powersync/lib-service-postgres Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here make sense and look good to me.

@simolus3 simolus3 force-pushed the rsocket-allow-json-requests branch from 523faec to a602fb2 Compare May 8, 2025 13:35
Copy link
Collaborator

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@simolus3 simolus3 merged commit d025bfd into main May 8, 2025
21 checks passed
@simolus3 simolus3 deleted the rsocket-allow-json-requests branch May 8, 2025 13:47
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.

3 participants