Skip to content

Commit

Permalink
Only send reload event when socket is open
Browse files Browse the repository at this point in the history
Reviewed By: sb98052

Differential Revision: D14604730

fbshipit-source-id: 4f7fdea3afefcfd757c4e291fb5670846f28813f
  • Loading branch information
Hypuk authored and facebook-github-bot committed Mar 25, 2019
1 parent de9f1c0 commit 3587eac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/metro-inspector-proxy/src/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ class Device {
if (message.event === 'getPages') {
this._pages = message.payload;
} else if (message.event === 'disconnect') {
// Device sends disconnect events only when page is reloaded.
// Device sends disconnect events only when page is reloaded or
// if debugger socket was disconnected.
const pageId = message.payload.pageId;
const debuggerSocket = this._debuggerSockets.get(pageId);
if (debuggerSocket) {
if (debuggerSocket && debuggerSocket.readyState == WS.OPEN) {
// eslint-disable-next-line no-console
console.log(chalk.green(`Page ${pageId} is reloading.`));
debuggerSocket.send(JSON.stringify({method: 'reload'}));
Expand Down

0 comments on commit 3587eac

Please sign in to comment.