Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect timers-promisified test case #37425

Closed
wants to merge 10 commits into from
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());
}