Packager - Fix symbolicate on windows

Summary:
There was an error with packager symbolization on Windows because it looks like `allowHalfOpen: true` doesn't work properly when using named sockets. This uses a random port on localhost for the connection instead on Windows as a workaround.

**Test plan**
Tested that symbolization works on both mac and windows by triggering a warning in UIExplorer.
Closes https://github.com/facebook/react-native/pull/13828

Differential Revision: D5019537

Pulled By: davidaurelio

fbshipit-source-id: 62c5b5f270e553a7d413bb4d1bab2406380f1d4f
This commit is contained in:
Janic Duplessis 2017-05-08 04:15:35 -07:00 committed by Facebook Github Bot
parent 5058e7eb05
commit 074fd33725
1 changed files with 6 additions and 1 deletions

View File

@ -30,7 +30,11 @@ const affixes = {prefix: 'metro-bundler-symbolicate', suffix: '.sock'};
const childPath = require.resolve('./worker');
exports.createWorker = (): Symbolicate => {
const socket = xpipe.eq(temp.path(affixes));
// There are issues with named sockets on windows that cause the connection to
// close too early so run the symbolicate server on a random localhost port.
const socket = process.platform === 'win32'
? 34712
: xpipe.eq(temp.path(affixes));
const child = new LockingPromise(new LazyPromise(() => startupChild(socket)));
return (stack, sourceMaps) =>
@ -53,6 +57,7 @@ function startupChild(socket) {
child.removeAllListeners();
resolve(child);
});
// $FlowFixMe ChildProcess.send should accept any type.
child.send(socket);
});
}