Fix issue where Flipper start starved

Summary: `yarn start` basically starves if watchman is still scanning the system, until that is completed (which took 40 minutes for me last time). Added a timeout of 1 minute, to signal that you can better to some dishes, instead of trying to hunt a bug that looks like an exception has been eaten somewhere (guess what I did..)

Reviewed By: timur-valiev

Differential Revision: D30806512

fbshipit-source-id: a2ebc3672d82f3388fc7b00f41c7e9c4f37794b3
This commit is contained in:
Michel Weststrate
2021-09-08 09:55:25 -07:00
committed by Facebook GitHub Bot
parent e1e9ca0f52
commit c3b2fe836d

View File

@@ -11,6 +11,8 @@ import {Client} from 'fb-watchman';
import {v4 as uuid} from 'uuid';
import path from 'path';
const watchmanTimeout = 60 * 1000;
export default class Watchman {
constructor(private rootDir: string) {}
@@ -31,6 +33,11 @@ export default class Watchman {
this.client!.end();
delete this.client;
};
const timeouthandle = setTimeout(() => {
onError(new Error('Timeout when trying to start Watchman'));
}, watchmanTimeout);
this.client!.once('error', onError);
this.client!.capabilityCheck(
{optional: [], required: ['relative_root']},
@@ -51,6 +58,7 @@ export default class Watchman {
}
this.watch = resp.watch;
this.relativeRoot = resp.relative_path;
clearTimeout(timeouthandle);
resolve();
},
);