From c3b2fe836dd1871a8b2a999643a33412ee8370b3 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Wed, 8 Sep 2021 09:55:25 -0700 Subject: [PATCH] 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 --- desktop/scripts/watchman.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/desktop/scripts/watchman.ts b/desktop/scripts/watchman.ts index e792f7b1b..ee25faef9 100644 --- a/desktop/scripts/watchman.ts +++ b/desktop/scripts/watchman.ts @@ -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(); }, );