Skip to content
Closed
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions test/parallel/test-timers-promisified.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,18 +392,23 @@ process.on('multipleResolves', common.mustNotCall());
// Check that the timing is correct
let pre = false;
let post = false;
setPromiseTimeout(1).then(() => pre = true);
const iterable = setInterval(() => {}, 2);
const iterator = iterable[Symbol.asyncIterator]();

iterator.next().then(common.mustCall(() => {
assert.ok(pre, 'interval ran too early');
assert.ok(!post, 'interval ran too late');
return iterator.next();
})).then(common.mustCall(() => {
assert.ok(post, 'second interval ran too early');
return iterator.return();
}));

setPromiseTimeout(3).then(() => post = true);
const time_unit = common.platformTimeout(50);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional nit: Since the problem we've been seeing is with the test being flaky on a fast machine, I wonder if common.platformTimeout() isn't needed here. It's usually for giving slow machines more time, but the problem we're seeing right now is the other way around--our LinuxONE host is too efficient.

Promise.all([
setPromiseTimeout(1).then(() => pre = true),
new Promise((res) => {
const iterable = timerPromises.setInterval(time_unit * 2);
const iterator = iterable[Symbol.asyncIterator]();

iterator.next().then(() => {
assert.ok(pre, 'interval ran too early');
assert.ok(!post, 'interval ran too late');
return iterator.next();
}).then(() => {
assert.ok(post, 'second interval ran too early');
return iterator.return();
}).then(res);
}),
setPromiseTimeout(time_unit * 3).then(() => post = true)
]).then(common.mustCall());
}