-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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']); | ||
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))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure you ran |
||
|
||
} else if (cluster.isMaster) { | ||
process.on('uncaughtException', () => process.nextTick(() => process.exit(MAGIC_EXIT_CODE))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
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.
I think this
var
can be aconst
too, no?