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

test: adding mustCall in test-timers-unrefed-in-callback.js #12594

Closed
Changes from 1 commit
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
15 changes: 5 additions & 10 deletions test/parallel/test-timers-unrefed-in-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Checks that setInterval timers keep running even when they're
// unrefed within their callback.

require('../common');
const assert = require('assert');
const common = require('../common');
const net = require('net');

let counter1 = 0;
Expand All @@ -28,15 +27,15 @@ function Test1() {
// server only for maintaining event loop
const server = net.createServer().listen(0);

const timer1 = setInterval(() => {
const timer1 = setInterval(common.mustCall(() => {
timer1.unref();
if (counter1++ === 3) {
clearInterval(timer1);
server.close(() => {
Test2();
});
}
}, 1);
}, 4), 1);
}


Expand All @@ -47,15 +46,11 @@ function Test2() {
// server only for maintaining event loop
const server = net.createServer().listen(0);

const timer2 = setInterval(() => {
const timer2 = setInterval(common.mustCall(() => {
timer2.unref();
if (counter2++ === 3)
server.close();
}, 1);
}, 4), 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this change is correct, especially given the comment block preceding this second test.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it is, but it isn't what are testing so it was left out of the original.

}

process.on('exit', () => {
assert.strictEqual(counter1, 4);
});

Test1();