mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 21:53:35 +03:00
fix: work-around electron's broken event loop (#5867)
Since `setImmediate` doesn't create a new task in Electron, we have to fallback to `setTimeout` instead. See https://github.com/electron/electron/issues/28261 for details. Fixes #5228
This commit is contained in:
parent
dfb1c99ad1
commit
9a50304dc1
@ -24,6 +24,11 @@ const mkdirAsync = util.promisify(fs.mkdir.bind(fs));
|
||||
|
||||
// See https://joel.tools/microtasks/
|
||||
export function makeWaitForNextTask() {
|
||||
// As of Mar 2021, Electorn v12 doesn't create new task with `setImmediate` despite
|
||||
// using Node 14 internally, so we fallback to `setTimeout(0)` instead.
|
||||
// @see https://github.com/electron/electron/issues/28261
|
||||
if (process.versions.electron)
|
||||
return (callback: () => void) => setTimeout(callback, 0);
|
||||
if (parseInt(process.versions.node, 10) >= 11)
|
||||
return setImmediate;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user