Skip to content

Commit

Permalink
Fixed concurrency issue in remote debugger
Browse files Browse the repository at this point in the history
Reviewed By: rafeca

Differential Revision: D8316215

fbshipit-source-id: 70b5000a9bf09897bb9b9d505bfc5dcc7c4c3a41
  • Loading branch information
Martin Sherburn authored and facebook-github-bot committed Jun 8, 2018
1 parent a52d84d commit e5aa5b7
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions local-cli/server/util/debugger-ui/index.html
Original file line number Diff line number Diff line change
@@ -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.
-->
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}
};

Expand Down

0 comments on commit e5aa5b7

Please sign in to comment.