From f9b1658c6fc9b99fde1d3799e46fe2c076e0048b Mon Sep 17 00:00:00 2001 From: Amjad Masad Date: Tue, 1 Sep 2015 11:51:51 -0700 Subject: [PATCH 1/3] [react-pacakger] Max idle time for socket server is too long --- react-packager/src/SocketInterface/SocketServer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-packager/src/SocketInterface/SocketServer.js b/react-packager/src/SocketInterface/SocketServer.js index d3cb752d..b292b2bf 100644 --- a/react-packager/src/SocketInterface/SocketServer.js +++ b/react-packager/src/SocketInterface/SocketServer.js @@ -15,7 +15,7 @@ const debug = require('debug')('ReactPackager:SocketServer'); const fs = require('fs'); const net = require('net'); -const MAX_IDLE_TIME = 10 * 60 * 1000; +const MAX_IDLE_TIME = 30 * 1000; class SocketServer { constructor(sockPath, options) { @@ -118,7 +118,7 @@ class SocketServer { this._deathTimer = setTimeout(() => { if (this._jobs <= 0) { debug('server dying', process.pid); - process.exit(1); + process.exit(); } this._dieEventually(); }, MAX_IDLE_TIME); From c48ce25de6ce764839250b2c059fe1c6b9220ca4 Mon Sep 17 00:00:00 2001 From: Amjad Masad Date: Tue, 1 Sep 2015 16:40:47 -0700 Subject: [PATCH 2/3] [react-packager] Fix cache issues --- react-packager/src/lib/getCacheFilePath.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-packager/src/lib/getCacheFilePath.js b/react-packager/src/lib/getCacheFilePath.js index d5ef19b3..1d858529 100644 --- a/react-packager/src/lib/getCacheFilePath.js +++ b/react-packager/src/lib/getCacheFilePath.js @@ -12,7 +12,7 @@ const crypto = require('crypto'); const path = require('path'); const tmpdir = require('os').tmpDir(); -function getCacheFilePath(args) { +function getCacheFilePath(...args) { args = Array.prototype.slice.call(args); const prefix = args.shift(); From 672b7b00703cda87e46d8517ba5e847bd4091184 Mon Sep 17 00:00:00 2001 From: Amjad Masad Date: Wed, 2 Sep 2015 15:40:26 -0700 Subject: [PATCH 3/3] [react-packager] Sourcemap url should include the same args as the bundle url Summary: Sourcemap urls were generated as just the pathname (no options) which meant that they generated source for the wrong bundle. Even worse, there exists a race condition when multiple request to the same bundle has different types of paltform arguments (in this case one could be 'ios' and the other is undefined). The fix will this will come later as it's more involved -- will need to refactor the dependency resolver to have a per-request state. --- react-packager/src/Server/__tests__/Server-test.js | 4 ++-- react-packager/src/Server/index.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/react-packager/src/Server/__tests__/Server-test.js b/react-packager/src/Server/__tests__/Server-test.js index 9e0a6890..5152054e 100644 --- a/react-packager/src/Server/__tests__/Server-test.js +++ b/react-packager/src/Server/__tests__/Server-test.js @@ -125,7 +125,7 @@ describe('processRequest', () => { expect(Bundler.prototype.bundle).toBeCalledWith( 'index.js', true, - 'index.map', + 'index.map?platform=ios', true, 'ios', ); @@ -270,7 +270,7 @@ describe('processRequest', () => { expect(Bundler.prototype.bundle).toBeCalledWith( 'path/to/foo.js', false, - '/path/to/foo.map', + '/path/to/foo.map?dev=false&runModule=false', false, undefined ); diff --git a/react-packager/src/Server/index.js b/react-packager/src/Server/index.js index 1ad6d862..d727fd52 100644 --- a/react-packager/src/Server/index.js +++ b/react-packager/src/Server/index.js @@ -429,8 +429,11 @@ class Server { return true; }).join('.') + '.js'; + const sourceMapUrlObj = _.clone(urlObj); + sourceMapUrlObj.pathname = pathname.replace(/\.bundle$/, '.map'); + return { - sourceMapUrl: pathname.replace(/\.bundle$/, '.map'), + sourceMapUrl: url.format(sourceMapUrlObj), entryFile: entryFile, dev: this._getBoolOptionFromQuery(urlObj.query, 'dev', true), minify: this._getBoolOptionFromQuery(urlObj.query, 'minify'),