Skip to content

Instantly share code, notes, and snippets.

@mactive
Last active June 23, 2016 07:57
Show Gist options
  • Save mactive/e3c8f76cd59a26d5d8353b8542374ac1 to your computer and use it in GitHub Desktop.
Save mactive/e3c8f76cd59a26d5d8353b8542374ac1 to your computer and use it in GitHub Desktop.
Dive Deep React Native Debugging
// file location
// node_module/react-native/local-cli/server/runServer.js
function runServer(args, config, readyCallback) {
var wsProxy = null;
const packagerServer = getPackagerServer(args, config);
const app = connect()
.use(loadRawBodyMiddleware)
.use(connect.compress())
.use(getDevToolsMiddleware(args, () => wsProxy && wsProxy.isChromeConnected()))
.use(openStackFrameInEditorMiddleware)
.use(statusPageMiddleware)
.use(systraceProfileMiddleware)
.use(cpuProfilerMiddleware)
.use(packagerServer.processRequest.bind(packagerServer));
args.projectRoots.forEach(root => app.use(connect.static(root)));
app.use(connect.logger())
.use(connect.errorHandler());
const serverInstance = http.createServer(app).listen(
args.port,
args.host,
function() {
attachHMRServer({
httpServer: serverInstance,
path: '/hot',
packagerServer,
});
wsProxy = webSocketProxy.attachToServer(serverInstance, '/debugger-proxy');
webSocketProxy.attachToServer(serverInstance, '/devtools');
readyCallback();
}
);
// Disable any kind of automatic timeout behavior for incoming
// requests in case it takes the packager more than the default
// timeout of 120 seconds to respond to a request.
serverInstance.timeout = 0;
}
@mactive
Copy link
Author

mactive commented Jun 23, 2016

runserver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment