Skip to content

Commit c787866

Browse files
Alexandre Kirszenbergfacebook-github-bot
Alexandre Kirszenberg
authored andcommitted
Clearer HMR error messages
Summary: GraphNotFoundError: When the user moves the app to the background on Android, restarts the Metro server and reopens the app, since the client hasn't requested either a delta or a bundle, the graph cache of the server is empty and thus we can't compute an update for the client (what if changes happened when the metro server was down?). RevisionNotFoundError: I didn't manage to reproduce that one. It could happen if two clients live side-by-side, requesting the exact same bundle. In the future, if we want to handle that case, we'll need to manage a list of clients listening to a single graph so that we don't try to update the same graph multiple times for a single file change. Disconnection: Same as GraphNotFoundError, but happens when the user moves the app to the background on iOS. Reviewed By: mjesun Differential Revision: D12960939 fbshipit-source-id: 5ac1dc7fd12bad5e0ee8dfa5a21c112773454ee5
1 parent bea57d8 commit c787866

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Libraries/Utilities/HMRClient.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,27 @@ Error: ${e.message}`;
8989

9090
hmrClient.on('error', data => {
9191
HMRLoadingView.hide();
92-
throw new Error(`${data.type} ${data.message}`);
92+
93+
if (data.type === 'GraphNotFoundError') {
94+
hmrClient.disable();
95+
throw new Error(
96+
'The packager server has restarted since the last Hot update. Hot Reloading will be disabled until you reload the application.',
97+
);
98+
} else if (data.type === 'RevisionNotFoundError') {
99+
hmrClient.disable();
100+
throw new Error(
101+
'The packager server and the client are out of sync. Hot Reloading will be disabled until you reload the application.',
102+
);
103+
} else {
104+
throw new Error(`${data.type} ${data.message}`);
105+
}
106+
});
107+
108+
hmrClient.on('close', data => {
109+
HMRLoadingView.hide();
110+
throw new Error(
111+
'Disconnected from the packager server. Hot Reloading will be disabled until you reload the application.',
112+
);
93113
});
94114

95115
hmrClient.enable();

0 commit comments

Comments
 (0)