fix: use Node's microtasks policy in node_main.cc (#23153)
Fixes #21515.
This commit is contained in:
parent
3ada079fe3
commit
07654c47ec
3 changed files with 40 additions and 0 deletions
23
spec/fixtures/module/node-promise-timer.js
vendored
Normal file
23
spec/fixtures/module/node-promise-timer.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
const waitMs = (msec) => new Promise((resolve) => setTimeout(resolve, msec));
|
||||
|
||||
const intervalMsec = 100;
|
||||
const numIterations = 2;
|
||||
let curIteration = 0;
|
||||
let promise;
|
||||
|
||||
for (let i = 0; i < numIterations; i++) {
|
||||
promise = (promise || waitMs(intervalMsec)).then(() => {
|
||||
++curIteration;
|
||||
return waitMs(intervalMsec);
|
||||
});
|
||||
}
|
||||
|
||||
// https://github.com/electron/electron/issues/21515 was about electron
|
||||
// exiting before promises finished. This test sets the pending exitCode
|
||||
// to failure, then resets it to success only if all promises finish.
|
||||
process.exitCode = 1;
|
||||
promise.then(() => {
|
||||
if (curIteration === numIterations) {
|
||||
process.exitCode = 0;
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue