From 1fbfdc58ebcf92d9a673dac630d641ded5f0262c Mon Sep 17 00:00:00 2001 From: Andrew <125917457+andrew-pledge-io@users.noreply.github.com> Date: Tue, 21 May 2024 11:17:39 +0100 Subject: [PATCH] fix: don't enter error state when request is aborted (#207) --- src/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0616e8a..e326dcc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -484,9 +484,14 @@ export class UnleashClient extends TinyEmitter { }); } } catch (e) { - console.error('Unleash: unable to fetch feature toggles', e); - this.sdkState = 'error'; - this.emit(EVENTS.ERROR, e); + if (!(e instanceof DOMException && e.name === 'AbortError')) { + console.error( + 'Unleash: unable to fetch feature toggles', + e + ); + this.sdkState = 'error'; + this.emit(EVENTS.ERROR, e); + } } finally { this.abortController = null; }