Skip to content
Permalink
Browse files

Tweak messages and fix the warning condition

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 2a3ac0429b0e4c443d185807a39b41fc5a2ab1d2
Showing with 6 additions and 6 deletions.
  1. +6 −6 Libraries/Utilities/HMRClient.js
@@ -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 += `
@@ -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}`;
@@ -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.',
);
});

@@ -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.)

0 comments on commit 2a3ac04

Please sign in to comment.
You can’t perform that action at this time.