From 3a012f5d465609ccc5d1dbab6cd58f7d554eb988 Mon Sep 17 00:00:00 2001 From: Alex Kotliarskyi Date: Fri, 24 Apr 2015 14:57:24 -0700 Subject: [PATCH 1/4] [ReactNative] Fix reloading in debug mode sometimes crashes packager --- webSocketProxy.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webSocketProxy.js b/webSocketProxy.js index 8223bbf2..f8636213 100644 --- a/webSocketProxy.js +++ b/webSocketProxy.js @@ -34,7 +34,12 @@ function attachToServer(server, path) { ws.on('message', function(message) { allClientsExcept(ws).forEach(function(cn) { - cn.send(message); + try { + // Sometimes this call throws 'not opened' + cn.send(message); + } catch(e) { + console.warn('WARN: ' + e.message); + } }); }); }); From 876f1084afda1f011c5751df9825fa2175e923f0 Mon Sep 17 00:00:00 2001 From: Spencer Ahrens Date: Mon, 27 Apr 2015 19:55:24 -0700 Subject: [PATCH 2/4] [ReactNative] temp disable flow check in packager for OSS --- packager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packager.js b/packager.js index 212e17f7..48552d93 100644 --- a/packager.js +++ b/packager.js @@ -213,7 +213,8 @@ function runServer( .use(openStackFrameInEditor) .use(getDevToolsLauncher(options)) .use(statusPageMiddleware) - .use(getFlowTypeCheckMiddleware(options)) + // Temporarily disable flow check until it's more stable + //.use(getFlowTypeCheckMiddleware(options)) .use(getAppMiddleware(options)); options.projectRoots.forEach(function(root) { From fca69ad9d5f7dd973801ca5526fab3f6e23514df Mon Sep 17 00:00:00 2001 From: Alex Kotliarskyi Date: Mon, 27 Apr 2015 19:33:01 -0700 Subject: [PATCH 3/4] [ReactNative] Bump watchman timeout to 25s --- react-packager/src/FileWatcher/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-packager/src/FileWatcher/index.js b/react-packager/src/FileWatcher/index.js index 38ad19bf..cd1a28e5 100644 --- a/react-packager/src/FileWatcher/index.js +++ b/react-packager/src/FileWatcher/index.js @@ -26,7 +26,7 @@ var detectingWatcherClass = new Promise(function(resolve) { module.exports = FileWatcher; -var MAX_WAIT_TIME = 10000; +var MAX_WAIT_TIME = 25000; // Singleton var fileWatcher = null; From 0fde2c25838a32985161f9c662a5a0b3c65af550 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Tue, 28 Apr 2015 15:55:42 -0700 Subject: [PATCH 4/4] JS: Use Object.defineProperty for Array Polyfills --- .../haste/polyfills/Array.prototype.es6.js | 82 +++++-------------- 1 file changed, 20 insertions(+), 62 deletions(-) diff --git a/react-packager/src/DependencyResolver/haste/polyfills/Array.prototype.es6.js b/react-packager/src/DependencyResolver/haste/polyfills/Array.prototype.es6.js index 8df5bbcc..80e62f05 100644 --- a/react-packager/src/DependencyResolver/haste/polyfills/Array.prototype.es6.js +++ b/react-packager/src/DependencyResolver/haste/polyfills/Array.prototype.es6.js @@ -3,53 +3,14 @@ * * @provides Array.prototype.es6 * @polyfill - * @requires __DEV__ */ /*eslint-disable */ /*jslint bitwise: true */ -(function (undefined) { - if (__DEV__) { - // Define DEV-only setter that blows up when someone incorrectly - // iterates over arrays. - try { - Object.defineProperty && Object.defineProperty( - Array.prototype, - '__ARRAY_ENUMERATION_GUARD__', - { - configurable: true, - enumerable: true, - get: function() { - console.error( - 'Your code is broken! Do not iterate over arrays with ' + - 'for...in.' - ); - } - } - ); - } catch (e) { - // Nothing - } - } - +(function(undefined) { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex function findIndex(predicate, context) { - /** - * Why am I seeing this "findIndex" method as a value in my array!? - * - * We polyfill the "findIndex" method -- called like - * `[1, 2, 3].findIndex(1)` -- for older browsers. A side effect of the way - * we do that is that the method is enumerable. If you were incorrectly - * iterating over your array using the object property iterator syntax - * `for (key in obj)` you will see the method name "findIndex" as a key. - * - * To fix your code please do one of the following: - * - * - Use a regular for loop with index. - * - Use one of the array methods: a.forEach, a.map, etc. - * - Guard your body of your loop with a `arr.hasOwnProperty(key)` check. - */ if (this == null) { throw new TypeError( 'Array.prototype.findIndex called on null or undefined' @@ -69,32 +30,29 @@ } if (!Array.prototype.findIndex) { - Array.prototype.findIndex = findIndex; + Object.defineProperty(Array.prototype, 'findIndex', { + enumerable: false, + writable: true, + configurable: true, + value: findIndex + }); } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find if (!Array.prototype.find) { - Array.prototype.find = function(predicate, context) { - /** - * Why am I seeing this "find" method as a value in my array!? - * - * We polyfill the "find" method -- called like - * `[1, 2, 3].find(1)` -- for older browsers. A side effect of the way - * we do that is that the method is enumerable. If you were incorrectly - * iterating over your array using the object property iterator syntax - * `for (key in obj)` you will see the method name "find" as a key. - * - * To fix your code please do one of the following: - * - * - Use a regular for loop with index. - * - Use one of the array methods: a.forEach, a.map, etc. - * - Guard your body of your loop with a `arr.hasOwnProperty(key)` check. - */ - if (this == null) { - throw new TypeError('Array.prototype.find called on null or undefined'); + Object.defineProperty(Array.prototype, 'find', { + enumerable: false, + writable: true, + configurable: true, + value: function(predicate, context) { + if (this == null) { + throw new TypeError( + 'Array.prototype.find called on null or undefined' + ); + } + var index = findIndex.call(this, predicate, context); + return index === -1 ? undefined : this[index]; } - var index = findIndex.call(this, predicate, context); - return index === -1 ? undefined : this[index]; - }; + }); } })();