Skip to content

Fix new sync client with RNQS #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/weak-chairs-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/react-native': patch
---

Fix issues forwarding array buffers to Rust sync client.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@azure/core-asynciterator-polyfill';

import { createBaseLogger, LogLevel, PowerSyncDatabase } from '@powersync/react-native';
import { createBaseLogger, LogLevel, PowerSyncDatabase, SyncClientImplementation } from '@powersync/react-native';
import React from 'react';
import { SupabaseStorageAdapter } from '../storage/SupabaseStorageAdapter';

Expand Down Expand Up @@ -68,7 +68,7 @@ export class System {

async init() {
await this.powersync.init();
await this.powersync.connect(this.supabaseConnector);
await this.powersync.connect(this.supabaseConnector, { clientImplementation: SyncClientImplementation.RUST });

if (this.attachmentQueue) {
await this.attachmentQueue.init();
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native/src/db/PowerSyncDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
DBAdapter,
PowerSyncBackendConnector,
PowerSyncDatabaseOptionsWithSettings,
type RequiredAdditionalConnectionOptions,
SqliteBucketStorage
type RequiredAdditionalConnectionOptions
} from '@powersync/common';
import { ReactNativeRemote } from '../sync/stream/ReactNativeRemote';
import { ReactNativeStreamingSyncImplementation } from '../sync/stream/ReactNativeStreamingSyncImplementation';
import { ReactNativeQuickSqliteOpenFactory } from './adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory';
import { ReactNativeBucketStorageAdapter } from './../sync/bucket/ReactNativeBucketStorageAdapter';

/**
* A PowerSync database which provides SQLite functionality
Expand Down Expand Up @@ -39,7 +39,7 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
}

protected generateBucketStorageAdapter(): BucketStorageAdapter {
return new SqliteBucketStorage(this.database, AbstractPowerSyncDatabase.transactionMutex);
return new ReactNativeBucketStorageAdapter(this.database, AbstractPowerSyncDatabase.transactionMutex);
}

protected generateSyncStreamImplementation(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { PowerSyncControlCommand, SqliteBucketStorage } from '@powersync/common';

export class ReactNativeBucketStorageAdapter extends SqliteBucketStorage {
control(op: PowerSyncControlCommand, payload: string | ArrayBuffer | null): Promise<string> {
if (payload != null && typeof payload != 'string') {
// For some reason, we need to copy array buffers for RNQS to recognize them. We're doing that here because we
// don't want to pay the cost of a copy on platforms where it's not necessary.
payload = new Uint8Array(payload).buffer;
}

return super.control(op, payload);
}
}
Loading