Skip to content

Commit 20588a6

Browse files
martinbigioFacebook Github Bot 4
authored andcommitted
Log HMR events
Summary:We've received reports saying that sometimes HRM updates take a couple of seconds to get applied. The feature is very optimized so that it takes around 100ms for most common type of changes. Only changes that require rebuilding caches could take longer than that, maybe up to 1 second. We think the problem is that watchman delays sending the file change notification because the system is under heavy use. It worth mentioning this is not a watchman issue!. This could happen for instance if flow is enabled. So, to better understand what's going on lets log when a file is changed and just before sending the HMR update to the client. The client codepath is extremelly fast so no need to log any of that. Reviewed By: davidaurelio Differential Revision: D2978694 fb-gh-sync-id: abd3b473d0b7ac7cd4461effce9813ccfda32c2b shipit-source-id: abd3b473d0b7ac7cd4461effce9813ccfda32c2b
1 parent f420f81 commit 20588a6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

local-cli/server/util/attachHMRServer.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ function attachHMRServer({httpServer, path, packagerServer}) {
111111
if (!client) {
112112
return;
113113
}
114+
console.log(
115+
`[Hot Module Replacement] File change detected (${time()})`
116+
);
114117

115118
client.ws.send(JSON.stringify({type: 'update-start'}));
116119
stat.then(() => {
@@ -230,6 +233,10 @@ function attachHMRServer({httpServer, path, packagerServer}) {
230233
return;
231234
}
232235

236+
console.log(
237+
'[Hot Module Replacement] Sending HMR update to client (' +
238+
time() + ')'
239+
);
233240
client.ws.send(update);
234241
});
235242
},
@@ -263,4 +270,9 @@ function arrayEquals(arrayA, arrayB) {
263270
);
264271
}
265272

273+
function time() {
274+
const date = new Date();
275+
return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}:${date.getMilliseconds()}`;
276+
}
277+
266278
module.exports = attachHMRServer;

0 commit comments

Comments
 (0)