From f1c2fdfac0fa88b157854a55b02809456fbd3636 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Thu, 4 Sep 2025 14:03:42 +0200 Subject: [PATCH 1/3] fix issue with broadcast channel --- packages/event-bus/src/client/client.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/event-bus/src/client/client.ts b/packages/event-bus/src/client/client.ts index 4d5123b0..aa33f3bf 100644 --- a/packages/event-bus/src/client/client.ts +++ b/packages/event-bus/src/client/client.ts @@ -55,7 +55,7 @@ export class ClientEventBus { this.#connectToServerBus = connectToServerBus this.#eventTarget = this.getGlobalTarget() this.#broadcastChannel.onmessage = (e) => { - this.emitToClients(e.data, true) + this.emitToClients(JSON.parse(e.data), true) } this.debugLog('Initializing client event bus') } @@ -74,7 +74,7 @@ export class ClientEventBus { // We only emit the events if they didn't come from the broadcast channel // otherwise it would infinitely send events between if (!fromBroadcastChannel) { - this.#broadcastChannel?.postMessage(event) + this.#broadcastChannel?.postMessage(JSON.stringify(event)) } this.debugLog('Emitting event to global client listeners', event) this.#eventTarget.dispatchEvent(globalEvent) @@ -94,7 +94,7 @@ export class ClientEventBus { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: json, - }).catch(() => {}) + }).catch(() => { }) } } start() { @@ -187,6 +187,6 @@ export class ClientEventBus { try { const event = JSON.parse(data) as TanStackDevtoolsEvent this.emitToClients(event) - } catch {} + } catch { } } } From ce29052f317d1ce19b131810da0ba05189a9f66e Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Thu, 4 Sep 2025 14:04:33 +0200 Subject: [PATCH 2/3] add changeset --- .changeset/little-buttons-sip.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/little-buttons-sip.md diff --git a/.changeset/little-buttons-sip.md b/.changeset/little-buttons-sip.md new file mode 100644 index 00000000..7ec2d898 --- /dev/null +++ b/.changeset/little-buttons-sip.md @@ -0,0 +1,5 @@ +--- +'@tanstack/devtools-event-bus': patch +--- + +fix issue with broadcast channel not emitting functions properly and failing From dc0b00c76ce7e45b7a1a1001603c283760109355 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 12:06:02 +0000 Subject: [PATCH 3/3] ci: apply automated fixes --- packages/event-bus/src/client/client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/event-bus/src/client/client.ts b/packages/event-bus/src/client/client.ts index aa33f3bf..55495786 100644 --- a/packages/event-bus/src/client/client.ts +++ b/packages/event-bus/src/client/client.ts @@ -94,7 +94,7 @@ export class ClientEventBus { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: json, - }).catch(() => { }) + }).catch(() => {}) } } start() { @@ -187,6 +187,6 @@ export class ClientEventBus { try { const event = JSON.parse(data) as TanStackDevtoolsEvent this.emitToClients(event) - } catch { } + } catch {} } }