Skip to content

Commit

Permalink
Always grab current setImmediate in queueTask
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-codaio committed Nov 1, 2023
1 parent 4c01ec3 commit deee6f5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lib/scheduling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ function getSetImmediateFromJsdom() {
// transactions are marked as not active when the event loop runs. The next
// tick queue and microtask queue run within the current event loop macrotask,
// so they'd process database operations too quickly.
export const queueTask: (fn: () => void) => void =
globalThis.setImmediate ||
getSetImmediateFromJsdom() ||
((fn: () => void) => setTimeout(fn, 0));
export const queueTask = (fn: () => void): void => {
const setImmediate =
globalThis.setImmediate ||
getSetImmediateFromJsdom() ||
((fn: () => void) => setTimeout(fn, 0));
setImmediate(fn);
};

0 comments on commit deee6f5

Please sign in to comment.