Skip to content

test: refactor /parallel/test-cluster-uncaught-exception.js to ES6 #9239

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

Closed
wants to merge 2 commits into from
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
22 changes: 8 additions & 14 deletions test/parallel/test-cluster-uncaught-exception.js
Original file line number Diff line number Diff line change
@@ -4,26 +4,20 @@
// https://github.com/joyent/node/issues/2556

const common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var fork = require('child_process').fork;
const assert = require('assert');
const cluster = require('cluster');
const fork = require('child_process').fork;

var MAGIC_EXIT_CODE = 42;
const MAGIC_EXIT_CODE = 42;

var isTestRunner = process.argv[2] != 'child';
const isTestRunner = process.argv[2] !== 'child';

if (isTestRunner) {
var master = fork(__filename, ['child']);
Copy link
Member

Choose a reason for hiding this comment

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

I think this var can be a const too, no?

master.on('exit', common.mustCall(function(code) {
assert.strictEqual(code, MAGIC_EXIT_CODE);
}));
} else if (cluster.isMaster) {
process.on('uncaughtException', function() {
process.nextTick(function() {
process.exit(MAGIC_EXIT_CODE);
});
});
master.on('exit', common.mustCall(code => assert.strictEqual(code, MAGIC_EXIT_CODE)));
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure you ran make -j8 test (or just make test, either is fine) on these changes? I would expect the linter to complain about this line as being too long.


} else if (cluster.isMaster) {
process.on('uncaughtException', () => process.nextTick(() => process.exit(MAGIC_EXIT_CODE)));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is much less readable than the current code.

cluster.fork();
throw new Error('kill master');
} else { // worker