MCPcopy
hub / github.com/facebook/react / handleMessage

Function handleMessage

packages/react-devtools-core/src/backend.js:296–325  ·  view source on GitHub ↗
(event: MessageEvent)

Source from the content-addressed store, hash-verified

294 }
295
296 function handleMessage(event: MessageEvent) {
297 let data;
298 try {
299 if (typeof event.data === 'string') {
300 data = JSON.parse(event.data);
301 if (__DEBUG__) {
302 debug('WebSocket.onmessage', data);
303 }
304 } else {
305 throw Error();
306 }
307 } catch (e) {
308 console.error(
309 '[React DevTools] Failed to parse JSON: ' + (event.data: any),
310 );
311 return;
312 }
313 messageListeners.forEach(fn => {
314 try {
315 fn(data);
316 } catch (error) {
317 // jsc doesn't play so well with tracebacks that go into eval'd code,
318 // so the stack trace here will stop at the `eval()` call. Getting the
319 // message that caused the error is the best we can do for now.
320 console.log('[React DevTools] Error calling listener', data);
321 console.log('error:', error);
322 throw error;
323 }
324 });
325 }
326}
327
328type ConnectWithCustomMessagingOptions = {

Callers

nothing calls this directly

Calls 4

debugFunction · 0.70
errorMethod · 0.65
forEachMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected