mirror of
https://github.com/status-im/metro.git
synced 2025-01-22 00:50:52 +00:00
Added timeouts to fs operations in packager
Reviewed By: davidaurelio Differential Revision: D3316555 fbshipit-source-id: edf6e08569b6cb434219f4460367eec0827530fd
This commit is contained in:
parent
5fbd3751a0
commit
bd7114d00f
18
react-packager/src/AssetServer/index.js
vendored
18
react-packager/src/AssetServer/index.js
vendored
@ -16,9 +16,21 @@ const fs = require('fs');
|
|||||||
const getAssetDataFromName = require('node-haste').getAssetDataFromName;
|
const getAssetDataFromName = require('node-haste').getAssetDataFromName;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const stat = Promise.denodeify(fs.stat);
|
const createTimeoutPromise = (timeout) => new Promise((resolve, reject) => {
|
||||||
const readDir = Promise.denodeify(fs.readdir);
|
setTimeout(reject, timeout, 'fs operation timeout');
|
||||||
const readFile = Promise.denodeify(fs.readFile);
|
});
|
||||||
|
function timeoutableDenodeify(fsFunc, timeout) {
|
||||||
|
return function raceWrapper(...args) {
|
||||||
|
return new Promise.race([
|
||||||
|
createTimeoutPromise(timeout),
|
||||||
|
Promise.denodeify(fsFunc).apply(this, args)
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const stat = timeoutableDenodeify(fs.stat, 5000);
|
||||||
|
const readDir = timeoutableDenodeify(fs.readdir, 5000);
|
||||||
|
const readFile = timeoutableDenodeify(fs.readFile, 5000);
|
||||||
|
|
||||||
const validateOpts = declareOpts({
|
const validateOpts = declareOpts({
|
||||||
projectRoots: {
|
projectRoots: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user