From 812075366552bb757aaa00ff55ecccd1e1e4c5fa Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin <28902667+hoxyq@users.noreply.github.com> Date: Thu, 21 Aug 2025 18:28:33 +0100 Subject: [PATCH] [DevTools] fix: always send a response to fetch-file request in the extension (#34235) This fixes the displaying of "rendered by" section if owner stacks contained any native frames. This regressed after https://github.com/facebook/react/pull/34185, where we added the Suspense boundary for the StackTraceView. This fails because the Promise that is responsible for symbolication of the source is never getting resolved or rejected. Previously, we would just throw an Error without sending a corresponding message to the `main` script, and it would just cache a Promise that is never resolved, hence the Suspense boundary for "rendered by" section is never resolved. In a separate change, I think we need to update StackTraceView component to display `native` as location, instead of `:0`: Screenshot 2025-08-20 at 00 20 42 --- .../src/background/messageHandlers.js | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/react-devtools-extensions/src/background/messageHandlers.js b/packages/react-devtools-extensions/src/background/messageHandlers.js index 5afcd6aadc..cd07f8afbc 100644 --- a/packages/react-devtools-extensions/src/background/messageHandlers.js +++ b/packages/react-devtools-extensions/src/background/messageHandlers.js @@ -46,22 +46,26 @@ export function handleDevToolsPageMessage(message) { payload: {tabId, url}, } = message; - if (!tabId) { - throw new Error("Couldn't fetch file sources: tabId not specified"); + if (!tabId || !url) { + // Send a response straight away to get the Promise fulfilled. + chrome.runtime.sendMessage({ + source: 'react-devtools-background', + payload: { + type: 'fetch-file-with-cache-error', + url, + value: null, + }, + }); + } else { + chrome.tabs.sendMessage(tabId, { + source: 'devtools-page', + payload: { + type: 'fetch-file-with-cache', + url, + }, + }); } - if (!url) { - throw new Error("Couldn't fetch file sources: url not specified"); - } - - chrome.tabs.sendMessage(tabId, { - source: 'devtools-page', - payload: { - type: 'fetch-file-with-cache', - url, - }, - }); - break; }