From ddb120a7eef1db39736298fb740513e21325d925 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Thu, 25 Sep 2025 10:33:47 +0200 Subject: [PATCH 1/2] chore: fix side-effect issue caused by constructor trying to connect --- packages/event-bus-client/src/plugin.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/event-bus-client/src/plugin.ts b/packages/event-bus-client/src/plugin.ts index ded43304..10367069 100644 --- a/packages/event-bus-client/src/plugin.ts +++ b/packages/event-bus-client/src/plugin.ts @@ -188,11 +188,17 @@ export class EventClient< // wait to connect to the bus if (!this.#connected) { this.debugLog('Bus not available, will be pushed as soon as connected') - return this.#queuedEvents.push({ + this.#queuedEvents.push({ type: `${this.#pluginId}:${eventSuffix}`, payload, pluginId: this.#pluginId, }) + // start connection to event bus + if (typeof CustomEvent !== 'undefined') { + this.#connectFunction() + this.startConnectLoop() + } + return } // emit right now return this.emitEventToBus({ From 2dc62ab2481c66e92674392a255370982f1715dc Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Thu, 25 Sep 2025 10:37:39 +0200 Subject: [PATCH 2/2] fix --- packages/event-bus-client/src/plugin.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/event-bus-client/src/plugin.ts b/packages/event-bus-client/src/plugin.ts index 10367069..eae03a04 100644 --- a/packages/event-bus-client/src/plugin.ts +++ b/packages/event-bus-client/src/plugin.ts @@ -74,11 +74,6 @@ export class EventClient< this.#connected = false this.#connectIntervalId = null this.#connectEveryMs = 500 - - if (typeof CustomEvent !== 'undefined') { - this.#connectFunction() - this.startConnectLoop() - } } private startConnectLoop() {