Skip to content
This repository was archived by the owner on Aug 31, 2018. It is now read-only.

Commit 6805058

Browse files
seishunaddaleax
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: nodejs/node#16562 Fixes: nodejs/node#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 edd9d35 commit 6805058

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

lib/internal/bootstrap_node.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@
4444
NativeModule.require('internal/process/next_tick').setup();
4545
NativeModule.require('internal/process/stdio').setup();
4646

47-
const browserGlobals = !process._noBrowserGlobals;
48-
if (browserGlobals) {
49-
setupGlobalTimeouts();
50-
setupGlobalConsole();
51-
}
52-
5347
const perf = process.binding('performance');
5448
const {
5549
NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE,
@@ -81,6 +75,12 @@
8175

8276
_process.setupRawDebug();
8377

78+
const browserGlobals = !process._noBrowserGlobals;
79+
if (browserGlobals) {
80+
setupGlobalTimeouts();
81+
setupGlobalConsole();
82+
}
83+
8484
// Ensure setURLConstructor() is called before the native
8585
// URL::ToObject() method is used.
8686
NativeModule.require('internal/url');
Lines changed: 18 additions & 0 deletions
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)