Skip to content

Commit 403ccb6

Browse files
committed
lib: setup IPC channel before console
Initializing IOCP on the same fd twice can fail on Windows. Consequently, if the IPC channel uses fd 1 or 2 and the console is setup first, writing to the IPC channel will fail. PR-URL: #16562 Fixes: #16141 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e2ce130 commit 403ccb6

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

lib/internal/bootstrap_node.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@
3737
NativeModule.require('internal/process/next_tick').setup();
3838
NativeModule.require('internal/process/stdio').setup();
3939

40-
const browserGlobals = !process._noBrowserGlobals;
41-
if (browserGlobals) {
42-
setupGlobalTimeouts();
43-
setupGlobalConsole();
44-
}
45-
4640
const perf = process.binding('performance');
4741
const {
4842
NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE,
@@ -74,6 +68,12 @@
7468

7569
_process.setupRawDebug();
7670

71+
const browserGlobals = !process._noBrowserGlobals;
72+
if (browserGlobals) {
73+
setupGlobalTimeouts();
74+
setupGlobalConsole();
75+
}
76+
7777
// Ensure setURLConstructor() is called before the native
7878
// URL::ToObject() method is used.
7979
NativeModule.require('internal/url');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
5+
const spawn = require('child_process').spawn;
6+
7+
if (process.argv[2] === 'child') {
8+
process.send('hahah');
9+
return;
10+
}
11+
12+
const proc = spawn(process.execPath, [__filename, 'child'], {
13+
stdio: ['inherit', 'ipc', 'inherit']
14+
});
15+
16+
proc.on('exit', common.mustCall(function(code) {
17+
assert.strictEqual(code, 0);
18+
}));

0 commit comments

Comments
 (0)