From 62e8a8fe56a219554a28cdb5fffb4c5d839e0c04 Mon Sep 17 00:00:00 2001 From: ColCh Date: Fri, 12 Aug 2016 07:24:59 -0700 Subject: [PATCH] make fsop timeout injectable Summary: We have a weak build machine for React Native app: a poor Mac Book Air with HDD, which is very slow. So, fs operations sometimes fail because of timeout. We likely don't care about build time, but it's pretty annoying to restart builds sometimes. In this PR I make timeout injectable via environment variable. __USAGE__: export this variable into environment. It's measured in miliseconds. Example, for 1 minute timeout: `export REACT_NATIVE_FSOP_TIMEOUT=60000` If you don't specify it, it will remain default value: `15000` This should not break anything, but repair slow builds. Related to : #9373 , #8794 (I think so) This PR should handle case of issue and close #9373 Closes https://github.com/facebook/react-native/pull/9374 Differential Revision: D3709325 Pulled By: bestander fbshipit-source-id: b00c89e10d05362314546faea7a4524f3d327c97 --- react-packager/src/AssetServer/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/react-packager/src/AssetServer/index.js b/react-packager/src/AssetServer/index.js index f03196cc..589bded7 100644 --- a/react-packager/src/AssetServer/index.js +++ b/react-packager/src/AssetServer/index.js @@ -28,9 +28,11 @@ function timeoutableDenodeify(fsFunc, timeout) { }; } -const stat = timeoutableDenodeify(fs.stat, 15000); -const readDir = timeoutableDenodeify(fs.readdir, 15000); -const readFile = timeoutableDenodeify(fs.readFile, 15000); +const FS_OP_TIMEOUT = parseInt(process.env.REACT_NATIVE_FSOP_TIMEOUT, 10) || 15000; + +const stat = timeoutableDenodeify(fs.stat, FS_OP_TIMEOUT); +const readDir = timeoutableDenodeify(fs.readdir, FS_OP_TIMEOUT); +const readFile = timeoutableDenodeify(fs.readFile, FS_OP_TIMEOUT); const validateOpts = declareOpts({ projectRoots: {