From 8142eb58bcd467e1999eb6ff4a8fb71051205355 Mon Sep 17 00:00:00 2001 From: Christiaan Landman Date: Thu, 15 May 2025 10:22:07 +0200 Subject: [PATCH] Fixed issue where broadcast logger wasn't being passed to WebRemote, causing worker remote logs not to be broadcasted to the tab's logs. --- .changeset/honest-melons-laugh.md | 5 ++ .../worker/sync/SharedSyncImplementation.ts | 47 ++++++++++--------- 2 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 .changeset/honest-melons-laugh.md diff --git a/.changeset/honest-melons-laugh.md b/.changeset/honest-melons-laugh.md new file mode 100644 index 000000000..1eab0f3a6 --- /dev/null +++ b/.changeset/honest-melons-laugh.md @@ -0,0 +1,5 @@ +--- +'@powersync/web': patch +--- + +Fixed issue where broadcast logger wasn't being passed to WebRemote, causing worker remote logs not to be broadcasted to the tab's logs. diff --git a/packages/web/src/worker/sync/SharedSyncImplementation.ts b/packages/web/src/worker/sync/SharedSyncImplementation.ts index 65c0504e4..af2d96d70 100644 --- a/packages/web/src/worker/sync/SharedSyncImplementation.ts +++ b/packages/web/src/worker/sync/SharedSyncImplementation.ts @@ -306,28 +306,31 @@ export class SharedSyncImplementation // Create a new StreamingSyncImplementation for each connect call. This is usually done is all SDKs. return new WebStreamingSyncImplementation({ adapter: new SqliteBucketStorage(this.dbAdapter!, new Mutex(), this.logger), - remote: new WebRemote({ - fetchCredentials: async () => { - const lastPort = this.ports[this.ports.length - 1]; - return new Promise(async (resolve, reject) => { - const abortController = new AbortController(); - this.fetchCredentialsController = { - controller: abortController, - activePort: lastPort - }; - - abortController.signal.onabort = reject; - try { - this.logger.log('calling the last port client provider for credentials'); - resolve(await lastPort.clientProvider.fetchCredentials()); - } catch (ex) { - reject(ex); - } finally { - this.fetchCredentialsController = undefined; - } - }); - } - }), + remote: new WebRemote( + { + fetchCredentials: async () => { + const lastPort = this.ports[this.ports.length - 1]; + return new Promise(async (resolve, reject) => { + const abortController = new AbortController(); + this.fetchCredentialsController = { + controller: abortController, + activePort: lastPort + }; + + abortController.signal.onabort = reject; + try { + this.logger.log('calling the last port client provider for credentials'); + resolve(await lastPort.clientProvider.fetchCredentials()); + } catch (ex) { + reject(ex); + } finally { + this.fetchCredentialsController = undefined; + } + }); + } + }, + this.logger + ), uploadCrud: async () => { const lastPort = this.ports[this.ports.length - 1];