Tweak error message for HMR

Summary:The error messages are iOS specific right now. This PR improves them to include the Android bits also.

![screenshot_20160322-000431](https://cloud.githubusercontent.com/assets/1174278/13929839/2bccce5e-efc2-11e5-9db3-f72dcf486412.png)
Closes https://github.com/facebook/react-native/pull/6546

Differential Revision: D3077815

Pulled By: martinbigio

fb-gh-sync-id: 344430d350023e78bd5fdae923eb4b6ce2924be5
shipit-source-id: 344430d350023e78bd5fdae923eb4b6ce2924be5
This commit is contained in:
Satyajit Sahoo 2016-03-21 14:07:09 -07:00 committed by Facebook Github Bot 3
parent 2a2ba4bd6b
commit 97a97b3c11
2 changed files with 25 additions and 7 deletions

View File

@ -40,18 +40,36 @@ const HMRClient = {
const activeWS = new WebSocket(wsUrl);
activeWS.onerror = (e) => {
throw new Error(
let error = (
`Hot loading isn't working because it cannot connect to the development server.
Ensure the following:
- Node server is running and available on the same network
- run 'npm start' from react-native root
- Node server URL is correctly set in AppDelegate
Try the following to fix the issue:
- Ensure that the packager server is running and available on the same network`
);
if (Platform.OS === 'ios') {
error += (
`
- Ensure that the Packager server URL is correctly set in AppDelegate`
);
} else {
error += (
`
- Ensure that your device/emulator is connected to your machine and has USB debugging enabled - run 'adb devices' to see a list of connected devices
- If you're on a physical device connected to the same machine, run 'adb reverse tcp:8081 tcp:8081' to forward requests from your device
- If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings' to your machine's IP address and the port of the local dev server - e.g. 10.0.1.1:8081`
);
}
error += (
`
URL: ${host}:${port}
Error: ${e.message}`
);
throw new Error(error);
};
activeWS.onmessage = ({data}) => {
// Moving to top gives errors due to NativeModules not being initialized

View File

@ -194,12 +194,12 @@ public class DevServerHelper {
StringBuilder sb = new StringBuilder();
sb.append("Could not connect to development server.\n\n")
.append("URL: ").append(request.urlString()).append("\n\n")
.append("Try the following to fix the issue:\n")
.append("\u2022 Ensure that the packager server is running\n")
.append("\u2022 Ensure that your device/emulator is connected to your machine and has USB debugging enabled - run 'adb devices' to see a list of connected devices\n")
.append("\u2022 If you're on a physical device connected to the same machine, run 'adb reverse tcp:8081 tcp:8081' to forward requests from your device\n")
.append("\u2022 If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings' to your machine's IP address and the port of the local dev server - e.g. 10.0.1.1:8081");
.append("\u2022 If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings' to your machine's IP address and the port of the local dev server - e.g. 10.0.1.1:8081\n\n")
.append("URL: ").append(request.urlString());
callback.onFailure(new DebugServerException(sb.toString()));
}