Skip to content

Commit

Permalink
Update promise-utils.ts
Browse files Browse the repository at this point in the history
Putting initial set of lastTick to current back from feedback

@msujew wrote:
If we interrupt to let other code run (i.e. how it's intended to be used, not just waiting on FireFox to do it's thing), the newly called code will then also call interruptAndCheck which immediately results in another next tick delay. We don't want that, so we would need to update the lastTick before and after running the delay.
  • Loading branch information
thejoecode authored Jan 13, 2025
1 parent 1959292 commit 789d4e8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/langium/src/utils/promise-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export async function interruptAndCheck(token: CancellationToken): Promise<void>
}
const current = performance.now();
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
Expand Down

0 comments on commit 789d4e8

Please sign in to comment.