From 8a6b67f9a57c700763ef082e6ee566535efe2c58 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Tue, 19 Nov 2024 10:10:13 -0300 Subject: [PATCH] Fix wrong error log --- CHANGES.txt | 1 + src/useSplitClient.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 273471a..160760d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.0.1 (November XX, 2024) + - Updated internal handling of the `updateOnSdkTimedout` param to remove the wrong log "[ERROR] A listener was added for SDK_READY_TIMED_OUT on the SDK, which has already fired and won't be emitted again". - Bugfixing - Fixed an issue with the `updateOn***` object parameters of the `useSplitClient` and `useSplitTreatments` hooks, and their components and HOCs alternatives, which were not defaulting to `true` when a non-boolean value was provided. 2.0.0 (November 1, 2024) diff --git a/src/useSplitClient.ts b/src/useSplitClient.ts index 42e48f4..56d7fc9 100644 --- a/src/useSplitClient.ts +++ b/src/useSplitClient.ts @@ -59,8 +59,12 @@ export function useSplitClient(options?: IUseSplitClientOptions): ISplitContextV else if (!status.isReadyFromCache) update(); } if (updateOnSdkTimedout !== false) { - if (!statusOnEffect.hasTimedout) client.once(client.Event.SDK_READY_TIMED_OUT, update); - else if (!status.hasTimedout) update(); + if (!statusOnEffect.hasTimedout) { + // Required to avoid error log for event already emitted + if (!statusOnEffect.isReady) client.once(client.Event.SDK_READY_TIMED_OUT, update); + } else { + if (!status.hasTimedout) update(); + } } if (updateOnSdkUpdate !== false) client.on(client.Event.SDK_UPDATE, update);