Skip to content

Commit 629e4ca

Browse files
committed
Cleanup
1 parent 0b0b60e commit 629e4ca

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

packages/common/src/client/sync/bucket/SqliteBucketStorage.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -416,16 +416,6 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
416416

417417
async control(op: string, payload: string | ArrayBuffer | null): Promise<string> {
418418
return await this.writeTransaction(async (tx) => {
419-
if (payload == null || typeof payload == 'string') {
420-
console.log('starting op', op, payload);
421-
} else {
422-
console.log(
423-
'starting binary op',
424-
op,
425-
Array.prototype.map.call(new Uint8Array(payload), (x) => x.toString(16).padStart(2, '0')).join('')
426-
);
427-
}
428-
429419
const [[raw]] = await tx.executeRaw('SELECT powersync_control(?, ?)', [op, payload]);
430420
return raw;
431421
});

packages/common/src/client/sync/stream/AbstractRemote.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export type RemoteConnector = {
2020
const POWERSYNC_TRAILING_SLASH_MATCH = /\/+$/;
2121
const POWERSYNC_JS_VERSION = PACKAGE.version;
2222

23-
// Refresh at least 30 sec before it expires
24-
const REFRESH_CREDENTIALS_SAFETY_PERIOD_MS = 30_000;
2523
const SYNC_QUEUE_REQUEST_LOW_WATER = 5;
2624

2725
// Keep alive message is sent every period
@@ -340,7 +338,7 @@ export abstract class AbstractRemote {
340338
const stream = new DataStream({
341339
logger: this.logger,
342340
pressure: {
343-
lowWaterMark: Math.max(1, Math.round(syncQueueRequestSize * 0.7))
341+
lowWaterMark: SYNC_QUEUE_REQUEST_LOW_WATER
344342
}
345343
});
346344

packages/common/src/client/sync/stream/AbstractStreamingSyncImplementation.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,10 @@ The next upload iteration will be delayed.`);
837837

838838
const abortController = new AbortController();
839839
signal.addEventListener('abort', () => abortController.abort());
840+
841+
// Pending sync lines received from the service, as well as local events that trigger a powersync_control
842+
// invocation (local events include refreshed tokens and completed uploads).
843+
// This is a single data stream so that we can handle all control calls from a single place.
840844
let controlInvocations: DataStream<[string, ArrayBuffer | string | undefined]> | null = null;
841845

842846
async function connect(instr: EstablishSyncStream) {
@@ -854,8 +858,7 @@ The next upload iteration will be delayed.`);
854858
...syncOptions,
855859
fetchStrategy: resolvedOptions.fetchStrategy
856860
},
857-
// TODO: Can we avoid the copy here?
858-
(buffer) => ['line_binary', new Uint8Array(buffer).buffer]
861+
(buffer) => ['line_binary', buffer]
859862
);
860863
}
861864

0 commit comments

Comments
 (0)