From a829dfdf12adcb7c4d03a478714a7ff02024ca94 Mon Sep 17 00:00:00 2001 From: thejoecode <1725110+thejoecode@users.noreply.github.com> Date: Thu, 23 Jan 2025 03:53:09 -0800 Subject: [PATCH] Improve `interruptAndCheck` behavior (#1787) --- packages/langium/src/utils/promise-utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/langium/src/utils/promise-utils.ts b/packages/langium/src/utils/promise-utils.ts index c7b8aea99..4540c4ace 100644 --- a/packages/langium/src/utils/promise-utils.ts +++ b/packages/langium/src/utils/promise-utils.ts @@ -78,6 +78,10 @@ export async function interruptAndCheck(token: CancellationToken): Promise if (current - lastTick >= globalInterruptionPeriod) { lastTick = current; await delayNextTick(); + // prevent calling delayNextTick every iteration of loop + // where delayNextTick takes up the majority or all of the + // globalInterruptionPeriod itself + lastTick = performance.now(); } if (token.isCancellationRequested) { throw OperationCancelled;