Skip to content

Commit 3163591

Browse files
committed
Fix possible server crash if OPENSSL_CONF is set
1 parent 712cb22 commit 3163591

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/index.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -381,22 +381,28 @@ if (!amMainInstance) {
381381
const serverBinPath = path.join(RESOURCES_PATH, 'httptoolkit-server', 'bin', binName);
382382
const serverBinCommand = isWindows ? `"${serverBinPath}"` : serverBinPath;
383383

384+
const envVars = {
385+
...process.env,
386+
387+
HTK_SERVER_TOKEN: AUTH_TOKEN,
388+
NODE_SKIP_PLATFORM_CHECK: '1',
389+
OPENSSL_CONF: undefined, // Not relevant to us, and if set this can crash Node.js
390+
391+
NODE_OPTIONS:
392+
process.env.HTTPTOOLKIT_NODE_OPTIONS || // Allow manually configuring node options
393+
[
394+
"--max-http-header-size=102400", // By default, set max header size to 100KB
395+
"--insecure-http-parser" // Allow invalid HTTP, e.g. header values - we'd rather be invisible than strict
396+
].join(' ')
397+
}
398+
384399
server = spawn(serverBinCommand, ['start'], {
385400
windowsHide: true,
386401
stdio: ['inherit', 'pipe', 'pipe'],
387402
shell: isWindows, // Required to spawn a .cmd script
388403
windowsVerbatimArguments: false, // Fixes quoting in windows shells
389404
detached: !isWindows, // Detach on Linux, so we can cleanly kill as a group
390-
env: Object.assign({}, process.env, {
391-
HTK_SERVER_TOKEN: AUTH_TOKEN,
392-
NODE_SKIP_PLATFORM_CHECK: '1',
393-
NODE_OPTIONS:
394-
process.env.HTTPTOOLKIT_NODE_OPTIONS || // Allow manually configuring node options
395-
[
396-
"--max-http-header-size=102400", // By default, set max header size to 100KB
397-
"--insecure-http-parser" // Allow invalid HTTP, e.g. header values - we'd rather be invisible than strict
398-
].join(' ')
399-
})
405+
env: envVars
400406
});
401407

402408
// Both not null because we pass 'pipe' for args 2 & 3 above.

0 commit comments

Comments
 (0)