From 2aac8bee19c38c0f47fd62ed34b408b077e20659 Mon Sep 17 00:00:00 2001 From: Michiel Date: Fri, 16 Jun 2023 12:22:03 +0200 Subject: [PATCH] fix: check whether tick has been removed before execution of function --- packages/@orbit/record-cache/src/live-query/live-query.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/@orbit/record-cache/src/live-query/live-query.ts b/packages/@orbit/record-cache/src/live-query/live-query.ts index 2ede80b3..f01f8e0c 100644 --- a/packages/@orbit/record-cache/src/live-query/live-query.ts +++ b/packages/@orbit/record-cache/src/live-query/live-query.ts @@ -171,8 +171,11 @@ function onceTick(fn: () => void) { if (!ticks.has(tick)) { ticks.add(tick); nextTick(() => { - fn(); - cancelTick(tick); + // Might have been cancelled + if (ticks.has(tick)) { + fn(); + cancelTick(tick); + } }); } };