Skip to content

Commit

Permalink
fix: 🐛 dont crash if setImmediate is not defined globally
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipoliko committed Jan 10, 2022
1 parent b3f9415 commit 356f5d6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/plugin-testing-integration/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { getConfig } from './configuration';
import { getBootConfigExtensions } from './bootConfigExtensions';
import { generateDictionary } from './localization';

const setIntervalNative = setInterval;
const setTimeoutNative = setTimeout;
const setImmediateNative = setImmediate;
const setIntervalNative = global.setInterval;
const setTimeoutNative = global.setTimeout;
const setImmediateNative = global.setImmediate;

let projectDependenciesLoaded = false;
let timers = [];
Expand Down Expand Up @@ -125,21 +125,21 @@ async function initImaApp(bootConfigMethods = {}) {
global.setInterval = (...args) => {
let timer = setIntervalNative(...args);

timers.push({ timer, clear: () => clearInterval(timer) });
timers.push({ timer, clear: () => global.clearInterval(timer) });

return timer;
};
global.setTimeout = (...args) => {
let timer = setTimeoutNative(...args);

timers.push({ timer, clear: () => clearTimeout(timer) });
timers.push({ timer, clear: () => global.clearTimeout(timer) });

return timer;
};
global.setImmediate = (...args) => {
let timer = setImmediateNative(...args);

timers.push({ timer, clear: () => clearImmediate(timer) });
timers.push({ timer, clear: () => global.clearImmediate(timer) });

return timer;
};
Expand Down

0 comments on commit 356f5d6

Please sign in to comment.