Skip to content

Commit 8c0c456

Browse files
seishungibfahn
authored andcommitted
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 3d8a7e9 commit 8c0c456

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
@@ -33,12 +33,6 @@
3333
NativeModule.require('internal/process/next_tick').setup();
3434
NativeModule.require('internal/process/stdio').setup();
3535

36-
const browserGlobals = !process._noBrowserGlobals;
37-
if (browserGlobals) {
38-
setupGlobalTimeouts();
39-
setupGlobalConsole();
40-
}
41-
4236
const perf = process.binding('performance');
4337
const {
4438
NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE,
@@ -70,6 +64,12 @@
7064

7165
_process.setupRawDebug();
7266

67+
const browserGlobals = !process._noBrowserGlobals;
68+
if (browserGlobals) {
69+
setupGlobalTimeouts();
70+
setupGlobalConsole();
71+
}
72+
7373
// Ensure setURLConstructor() is called before the native
7474
// URL::ToObject() method is used.
7575
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)