Fixed concurrency issue in remote debugger

Reviewed By: rafeca

Differential Revision: D8316215

fbshipit-source-id: 70b5000a9bf09897bb9b9d505bfc5dcc7c4c3a41
This commit is contained in:
Martin Sherburn 2018-06-08 02:57:15 -07:00 коммит произвёл Facebook Github Bot
Родитель a52d84d7e1
Коммит e5aa5b7c50
1 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -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);
}
}
};