Skip to content

Commit ea25ad0

Browse files
Martin Sherburnfacebook-github-bot
Martin Sherburn
authored andcommitted
Fixed concurrency issue in remote debugger
Reviewed By: rafeca Differential Revision: D8316215 fbshipit-source-id: 70b5000a9bf09897bb9b9d505bfc5dcc7c4c3a41
1 parent cc7b29f commit ea25ad0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

server/util/debugger-ui/index.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<!--
33
Copyright (c) 2015-present, Facebook, Inc.
4-
4+
55
This source code is licensed under the MIT license found in the
66
LICENSE file in the root directory of this source tree.
77
-->
@@ -112,6 +112,8 @@
112112
function connectToDebuggerProxy() {
113113
const ws = new WebSocket('ws://' + window.location.host + '/debugger-proxy?role=debugger&name=Chrome');
114114
let worker;
115+
let queuedMessages = [];
116+
let appExecuted = false;
115117

116118
function createJSRuntime() {
117119
// This worker will run the application JavaScript code,
@@ -181,9 +183,21 @@
181183
...object,
182184
url: await getBlobUrl(object.url),
183185
});
186+
appExecuted = true;
187+
// Flush any messages queued up and clear them
188+
for (const message of queuedMessages) {
189+
worker.postMessage(message);
190+
}
191+
queuedMessages = [];
184192
} else {
185-
// Otherwise, pass through to the worker.
186-
worker.postMessage(object);
193+
// Otherwise, pass through to the worker provided the
194+
// application script has been executed. If not add
195+
// it to a queue until it has been executed.
196+
if (appExecuted) {
197+
worker.postMessage(object);
198+
} else {
199+
queuedMessages.push(object);
200+
}
187201
}
188202
};
189203

0 commit comments

Comments
 (0)