From 5d99f7e92ec790362c225c0c601c2743dfd06683 Mon Sep 17 00:00:00 2001 From: Dan Wilt Date: Fri, 15 Jul 2022 11:39:03 -0400 Subject: [PATCH] fix(core): added in timer and interval id checks before clearing (#3762) --- src/core/query.ts | 6 ++++-- src/core/queryObserver.ts | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/core/query.ts b/src/core/query.ts index 3ad311054a..540be8b204 100644 --- a/src/core/query.ts +++ b/src/core/query.ts @@ -211,8 +211,10 @@ export class Query< } private clearGcTimeout() { - clearTimeout(this.gcTimeout) - this.gcTimeout = undefined + if (this.gcTimeout) { + clearTimeout(this.gcTimeout) + this.gcTimeout = undefined + } } private optionalRemove() { diff --git a/src/core/queryObserver.ts b/src/core/queryObserver.ts index 7dff4fb575..e3bec05611 100644 --- a/src/core/queryObserver.ts +++ b/src/core/queryObserver.ts @@ -433,13 +433,17 @@ export class QueryObserver< } private clearStaleTimeout(): void { - clearTimeout(this.staleTimeoutId) - this.staleTimeoutId = undefined + if (this.staleTimeoutId) { + clearTimeout(this.staleTimeoutId) + this.staleTimeoutId = undefined + } } private clearRefetchInterval(): void { - clearInterval(this.refetchIntervalId) - this.refetchIntervalId = undefined + if (this.refetchIntervalId) { + clearInterval(this.refetchIntervalId) + this.refetchIntervalId = undefined + } } protected createResult(