-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Remove debug
and inspect
flags from the arguments sent to the child
#5068
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 |
---|---|---|
|
@@ -21,9 +21,11 @@ import { | |
let Worker; | ||
let forkInterface; | ||
let childProcess; | ||
let properProcess; | ||
|
||
beforeEach(() => { | ||
jest.mock('child_process'); | ||
properProcess = process; | ||
|
||
childProcess = require('child_process'); | ||
childProcess.fork.mockImplementation(() => { | ||
|
@@ -41,14 +43,19 @@ beforeEach(() => { | |
|
||
afterEach(() => { | ||
jest.resetModules(); | ||
// eslint-disable-next-line no-native-reassign | ||
process = properProcess; | ||
}); | ||
|
||
it('passes fork options down to child_process.fork, adding the defaults', () => { | ||
const child = require.resolve('../child'); | ||
|
||
Object.assign(process, {execArgv: ['--inspect', '-p']}); | ||
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 find it funny that eslint does not yell at me for 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. The 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 don't really care that I modify it, it's sandboxed for this test in particular, right? Good idea on just messing with the part I need to mess with, though |
||
|
||
new Worker({ | ||
forkOptions: { | ||
cwd: '/tmp', | ||
execArgv: ['--no-warnings'], | ||
execPath: 'hello', | ||
}, | ||
maxRetries: 3, | ||
workerPath: '/tmp/foo/bar/baz.js', | ||
|
@@ -58,7 +65,8 @@ it('passes fork options down to child_process.fork, adding the defaults', () => | |
expect(childProcess.fork.mock.calls[0][1]).toEqual({ | ||
cwd: '/tmp', // Overridden default option. | ||
env: process.env, // Default option. | ||
execArgv: ['--no-warnings'], // Added option. | ||
execArgv: ['-p'], // Filtered option. | ||
execPath: 'hello', // Added option. | ||
silent: true, // Default option. | ||
}); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,9 @@ export default class { | |
{ | ||
cwd: process.cwd(), | ||
env: process.env, | ||
// suppress --debug / --inspect flags while preserving others (like --harmony) | ||
// inspired by https://github.com/rvagg/node-worker-farm/blob/f63d988c307a6805e03b1650f8ef0fb7ca6f1546/lib/fork.js | ||
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. Do we need the comment? :) 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. maybe not. It's a pure copy, though :P |
||
execArgv: process.execArgv.filter(v => !/^--(debug|inspect)/.test(v)), | ||
silent: true, | ||
}, | ||
this._options.forkOptions, | ||
|
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'd like ideas here...
require('process')
; and mock it properly?