fix: incorrect timers-promisified test case
This test case is incorrect, and it caused too many unit-test failures
https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel7-s390x/25697/testReport/ https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel7-s390x/25708/testReport/ ...
You can see it in this page: https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel7-s390x/ This is probably caused by a wrong time-sequence execution order. I'm trying to work on this.
Analysis
setPromiseTimeout(1).then(() => pre = true); // L1
const iterable = setInterval(() => {}, 2); // L2
//...
iterator.next().then(...); // L3
setPromiseTimeout(3).then(() => post = true); // L4
Assume we execute this code at time 0 Time=0, FinishExecute=L1, callback L1 is queued to execute at Time=1 Time=1, FinishExecute=L2, callback L2 is queued to execute at Time=3, 5, 7, ... Time=2, FinishExecute=L3 Time=11, FinishExecute=L4, callback L3 is queued to execute at Time=14
In this case, this unit test will throw an error 'second interval ran too early'
, but it is OK.
My solution
First, the timeout is 10, 20, 30 to tolerate the time for code-execution
Second, use the Promise.all
to wait for these three promises
I think it would work.