Skip to content

Commit 494d607

Browse files
wvengenfacebook-github-bot-9
authored andcommitted
Improve watcher timeout error message (fixes #5005)
Summary: Closes facebook/react-native#5022 Reviewed By: svcscm Differential Revision: D2793185 Pulled By: milend fb-gh-sync-id: ec49d27d6e405924269a48f32cce401b1ce380f6
1 parent 5bc45f1 commit 494d607

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

  • packager/react-packager/src/DependencyResolver/FileWatcher

packager/react-packager/src/DependencyResolver/FileWatcher/index.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ function createWatcher(rootConfig) {
9696

9797
return new Promise(function(resolve, reject) {
9898
const rejectTimeout = setTimeout(function() {
99-
reject(new Error([
100-
'Watcher took too long to load',
101-
'Try running `watchman version` from your terminal',
102-
'https://facebook.github.io/watchman/docs/troubleshooting.html',
103-
].join('\n')));
99+
reject(new Error(timeoutMessage(Watcher)));
104100
}, MAX_WAIT_TIME);
105101

106102
watcher.once('ready', function() {
@@ -111,4 +107,17 @@ function createWatcher(rootConfig) {
111107
});
112108
}
113109

110+
function timeoutMessage(Watcher) {
111+
const lines = [
112+
'Watcher took too long to load (' + Watcher.name + ')',
113+
];
114+
if (Watcher === sane.WatchmanWatcher) {
115+
lines.push(
116+
'Try running `watchman version` from your terminal',
117+
'https://facebook.github.io/watchman/docs/troubleshooting.html',
118+
);
119+
}
120+
return lines.join('\n');
121+
}
122+
114123
module.exports = FileWatcher;

0 commit comments

Comments
 (0)