Skip to content

Commit

Permalink
Tweak messages and fix the warning condition
Browse files Browse the repository at this point in the history
Summary:
Two changes:

1. If you're connected at startup, and then disconnect, we're supposed to show a yellow box. Looks like we weren't doing it for a few days because the field we were checking has turned into a method.

2. I changed the wording back to remove "Metro" since the packager may be Haul, for example. So I'm just calling it "development server". Does that seem reasonable? I also removed mentions of Fast Refresh since it's not actually relevant to the problem.

Reviewed By: cpojer

Differential Revision: D16459080

fbshipit-source-id: c9c1f19718d522c745e4107a3e7e3a6c63f82642
  • Loading branch information
gaearon authored and facebook-github-bot committed Jul 24, 2019
1 parent 8a80d61 commit 2a3ac04
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Libraries/Utilities/HMRClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ const HMRClient: HMRClientNativeInterface = {
);

client.on('connection-error', e => {
let error = `Fast Refresh isn't working because it cannot connect to the development server.
let error = `Cannot connect to the Metro server.
Try the following to fix the issue:
- Ensure that the Metro Server is running and available on the same network`;
- Ensure that the Metro server is running and available on the same network`;

if (Platform.OS === 'ios') {
error += `
Expand Down Expand Up @@ -190,12 +190,12 @@ Error: ${e.message}`;
if (data.type === 'GraphNotFoundError') {
client.close();
setHMRUnavailableReason(
'The Metro server has restarted since the last edit. Fast Refresh will be disabled until you reload the application.',
'The Metro server has restarted since the last edit. Reload to reconnect.',
);
} else if (data.type === 'RevisionNotFoundError') {
client.close();
setHMRUnavailableReason(
'The Metro server and the client are out of sync. Fast Refresh will be disabled until you reload the application.',
'The Metro server and the client are out of sync. Reload to reconnect.',
);
} else {
currentCompileErrorMessage = `${data.type} ${data.message}`;
Expand All @@ -208,7 +208,7 @@ Error: ${e.message}`;
client.on('close', data => {
LoadingView.hide();
setHMRUnavailableReason(
'Disconnected from the Metro server. Fast Refresh will be disabled until you reload the application.',
'Disconnected from the Metro server. Reload to reconnect.',
);
});

Expand All @@ -229,7 +229,7 @@ function setHMRUnavailableReason(reason) {
return;
}
hmrUnavailableReason = reason;
if (hmrClient.shouldApplyUpdates) {
if (hmrClient.isEnabled()) {
// If HMR is currently enabled, show a warning.
console.warn(reason);
// (Not using the `warning` module to prevent a Buck cycle.)
Expand Down

0 comments on commit 2a3ac04

Please sign in to comment.