-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: recommended changes to test-cluster-send-handle-twice.js #10049
Conversation
var client = net.connect({ host: 'localhost', port: common.PORT }); | ||
client.on('close', function() { cluster.worker.disconnect(); }); | ||
const client = net.connect({ host: 'localhost', port: common.PORT }); | ||
client.on('close', common.mustCall(function() { cluster.worker.disconnect(); })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change isn't really necessary (although it doesn't hurt anything). Nothing is being asserted in the callback, so the test should fail if it's not called.
const worker = cluster.fork(); | ||
worker.on('exit', common.mustCall(function(code, signal) { | ||
assert.strictEqual(code, 0, 'Worker exited with an error code'); | ||
assert.strictEqual(signal, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have left the 'Worker exited by a signal'
as the third argument here.
setTimeout(function() { client.end(); }, 50); | ||
}).on('error', function(e) { | ||
console.error(e); | ||
assert(false, 'server.listen failed'); | ||
common.fail('server.listen failed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bug was in the original test, but the next line will never execute because common.fail()
(and, in the existing test, assert(false, ...)
) result in the termination of the program.
Maybe @cjihrig @mcollina or @bnoordhuis can give this a quick review? (Looping in the people suggested for cluster stuff in onboarding-extras.md.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if CI is green
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if the CI is happy.
- `var` --> `const` as applicable - `assert.equal` --> `assert.strictEqual` - `assert(false, ..)` --> `common.fail()` - `common.mustCall` for functions that need to be called exactly once - modified an `assert(!signal, 'Worker exited by a signal');` call to `assert.strictEqual(signal, null);` call as that made more sense PR-URL: nodejs#10049 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Landed in 7e7062c. |
- `var` --> `const` as applicable - `assert.equal` --> `assert.strictEqual` - `assert(false, ..)` --> `common.fail()` - `common.mustCall` for functions that need to be called exactly once - modified an `assert(!signal, 'Worker exited by a signal');` call to `assert.strictEqual(signal, null);` call as that made more sense PR-URL: #10049 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- `var` --> `const` as applicable - `assert.equal` --> `assert.strictEqual` - `assert(false, ..)` --> `common.fail()` - `common.mustCall` for functions that need to be called exactly once - modified an `assert(!signal, 'Worker exited by a signal');` call to `assert.strictEqual(signal, null);` call as that made more sense PR-URL: #10049 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- `var` --> `const` as applicable - `assert.equal` --> `assert.strictEqual` - `assert(false, ..)` --> `common.fail()` - `common.mustCall` for functions that need to be called exactly once - modified an `assert(!signal, 'Worker exited by a signal');` call to `assert.strictEqual(signal, null);` call as that made more sense PR-URL: #10049 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- `var` --> `const` as applicable - `assert.equal` --> `assert.strictEqual` - `assert(false, ..)` --> `common.fail()` - `common.mustCall` for functions that need to be called exactly once - modified an `assert(!signal, 'Worker exited by a signal');` call to `assert.strictEqual(signal, null);` call as that made more sense PR-URL: #10049 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- `var` --> `const` as applicable - `assert.equal` --> `assert.strictEqual` - `assert(false, ..)` --> `common.fail()` - `common.mustCall` for functions that need to be called exactly once - modified an `assert(!signal, 'Worker exited by a signal');` call to `assert.strictEqual(signal, null);` call as that made more sense PR-URL: #10049 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- `var` --> `const` as applicable - `assert.equal` --> `assert.strictEqual` - `assert(false, ..)` --> `common.fail()` - `common.mustCall` for functions that need to be called exactly once - modified an `assert(!signal, 'Worker exited by a signal');` call to `assert.strictEqual(signal, null);` call as that made more sense PR-URL: #10049 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- `var` --> `const` as applicable - `assert.equal` --> `assert.strictEqual` - `assert(false, ..)` --> `common.fail()` - `common.mustCall` for functions that need to be called exactly once - modified an `assert(!signal, 'Worker exited by a signal');` call to `assert.strictEqual(signal, null);` call as that made more sense PR-URL: #10049 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
Description of change
var
-->const
as applicableassert.equal
-->assert.strictEqual
assert(false, ..)
-->common.fail()
common.mustCall
for functions that need to be called exactly onceassert(!signal, 'Worker exited by a signal');
call toassert.strictEqual(signal, null);
call as that made more sense