Skip to content

Commit

Permalink
test: improve known_issues/test-vm-timeout-escape-queuemicrotask
Browse files Browse the repository at this point in the history
Improve known_issues/test-vm-timeout-escape-queuemicrotask to mitigate
CI failures on ubuntu1604-arm64. Failures are due to a race condition.
Use `common.platformTimeout()` to help, adjust timeout to make sure
`queueMicrotasks()` has a chance to run, and improve error message.

PR-URL: #25503
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Coe <bencoe@gmail.com>
  • Loading branch information
Trott authored and addaleax committed Jan 15, 2019
1 parent 736349c commit 0b1a9aa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/known_issues/test-vm-timeout-escape-queuemicrotask.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ const NS_PER_MS = 1000000n;

const hrtime = process.hrtime.bigint;

const loopDuration = common.platformTimeout(100n);
const timeout = common.platformTimeout(10);

function loop() {
const start = hrtime();
while (1) {
const current = hrtime();
const span = (current - start) / NS_PER_MS;
if (span >= 100n) {
if (span >= loopDuration) {
throw new Error(
`escaped timeout at ${span} milliseconds!`);
`escaped ${timeout}ms timeout at ${span}ms`);
}
}
}
Expand All @@ -32,9 +35,9 @@ assert.throws(() => {
queueMicrotask,
loop
},
{ timeout: common.platformTimeout(5) }
{ timeout }
);
}, {
code: 'ERR_SCRIPT_EXECUTION_TIMEOUT',
message: 'Script execution timed out after 5ms'
message: `Script execution timed out after ${timeout}ms`
});

0 comments on commit 0b1a9aa

Please sign in to comment.