diff --git a/react-packager/src/SocketInterface/SocketClient.js b/react-packager/src/SocketInterface/SocketClient.js index 6ccfd481..32e3b25d 100644 --- a/react-packager/src/SocketInterface/SocketClient.js +++ b/react-packager/src/SocketInterface/SocketClient.js @@ -12,6 +12,7 @@ const Bundle = require('../Bundler/Bundle'); const Promise = require('promise'); const bser = require('bser'); const debug = require('debug')('ReactPackager:SocketClient'); +const fs = require('fs'); const net = require('net'); const path = require('path'); const tmpdir = require('os').tmpdir(); @@ -30,8 +31,13 @@ class SocketClient { this._ready = new Promise((resolve, reject) => { this._sock.on('connect', () => resolve(this)); this._sock.on('error', (e) => { - e.message = `Error connecting to server on ${sockPath}` + + e.message = `Error connecting to server on ${sockPath} ` + `with error: ${e.message}`; + + if (fs.existsSync(LOG_PATH)) { + e.message += '\nServer logs:\n' + fs.readFileSync(LOG_PATH, 'utf8'); + } + reject(e); }); }); diff --git a/react-packager/src/SocketInterface/SocketServer.js b/react-packager/src/SocketInterface/SocketServer.js index abdc094b..888dcf78 100644 --- a/react-packager/src/SocketInterface/SocketServer.js +++ b/react-packager/src/SocketInterface/SocketServer.js @@ -16,6 +16,7 @@ const fs = require('fs'); const net = require('net'); const MAX_IDLE_TIME = 30 * 1000; +const MAX_STARTUP_TIME = 5 * 60 * 1000; class SocketServer { constructor(sockPath, options) { @@ -43,7 +44,7 @@ class SocketServer { options.nonPersistent = true; this._packagerServer = new Server(options); this._jobs = 0; - this._dieEventually(); + this._dieEventually(MAX_STARTUP_TIME); } onReady() { @@ -118,7 +119,7 @@ class SocketServer { })); } - _dieEventually() { + _dieEventually(delay = MAX_IDLE_TIME) { clearTimeout(this._deathTimer); this._deathTimer = setTimeout(() => { if (this._jobs <= 0 && this._numConnections <= 0) { @@ -126,7 +127,7 @@ class SocketServer { process.exit(); } this._dieEventually(); - }, MAX_IDLE_TIME); + }, delay); } static listenOnServerIPCMessages() {