Skip to content

Commit a71c1a5

Browse files
committed
Reverted back listener, didn't see that one is worker and other is window... they have to be separate.
1 parent d5253d3 commit a71c1a5

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

app/middlewares/debuggerAPI.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ let socket;
3333
const workerOnMessage = message => {
3434
const { data } = message;
3535

36-
if (data && data.source === 'apollo-devtools-proxy') {
37-
const message = typeof data.payload === 'string' ? { event: data.payload } : data.payload;
38-
worker.postMessage({ source: 'apollo-devtools-proxy', ...message });
39-
}
40-
41-
if (data.source === 'apollo-devtools-backend') {
36+
if (data && data.source === 'apollo-devtools-backend') {
4237
if (!window.__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__) {
4338
window.__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__ = true;
4439
}
@@ -60,13 +55,22 @@ const workerOnMessage = message => {
6055
socket.send(JSON.stringify(data));
6156
};
6257

58+
const onWindowMessage = e => {
59+
const {data} = e;
60+
if (data && data.source === 'apollo-devtools-proxy') {
61+
const message = typeof data.payload === 'string' ? { event: data.payload } : data.payload;
62+
worker.postMessage({ source: 'apollo-devtools-proxy', ...message });
63+
}
64+
};
65+
6366
const createJSRuntime = () => {
6467
// This worker will run the application javascript code,
6568
// making sure that it's run in an environment without a global
6669
// document, to make it consistent with the JSC executor environment.
6770
// eslint-disable-next-line
6871
worker = new Worker(`${__webpack_public_path__}RNDebuggerWorker.js`);
6972
worker.addEventListener('message', workerOnMessage);
73+
window.addEventListener('message', onWindowMessage);
7074
actions.setDebuggerWorker(worker, 'connected');
7175
};
7276

@@ -75,6 +79,7 @@ const shutdownJSRuntime = () => {
7579
scriptExecuted = false;
7680
if (worker) {
7781
worker.terminate();
82+
window.removeEventListener('messsage', onWindowMessage);
7883
setDevMenuMethods([]);
7984
}
8085
worker = null;

0 commit comments

Comments
 (0)