Permalink
Browse files

Fixed concurrency issue in remote debugger

Reviewed By: rafeca

Differential Revision: D8316215

fbshipit-source-id: 70b5000a9bf09897bb9b9d505bfc5dcc7c4c3a41
  • Loading branch information...
MartinSherburn authored and facebook-github-bot committed Jun 8, 2018
1 parent a52d84d commit e5aa5b7c508c5e0e51f7abfcee350e27bef24ba2
Showing with 17 additions and 3 deletions.
  1. +17 −3 local-cli/server/util/debugger-ui/index.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<!--
Copyright (c) 2015-present, Facebook, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->
@@ -112,6 +112,8 @@
function connectToDebuggerProxy() {
const ws = new WebSocket('ws://' + window.location.host + '/debugger-proxy?role=debugger&name=Chrome');
let worker;
let queuedMessages = [];
let appExecuted = false;
function createJSRuntime() {
// This worker will run the application JavaScript code,
@@ -181,9 +183,21 @@
...object,
url: await getBlobUrl(object.url),
});
appExecuted = true;
// Flush any messages queued up and clear them
for (const message of queuedMessages) {
worker.postMessage(message);
}
queuedMessages = [];
} else {
// Otherwise, pass through to the worker.
worker.postMessage(object);
// Otherwise, pass through to the worker provided the
// application script has been executed. If not add
// it to a queue until it has been executed.
if (appExecuted) {
worker.postMessage(object);
} else {
queuedMessages.push(object);
}
}
};

0 comments on commit e5aa5b7

Please sign in to comment.