Conversation
Summary: Typing an expression into the DevTools console and then asking for its source failed with "Unable to fetch script source." Easiest repro: type `debugger;`, execution pauses, and the Sources panel has nothing to show. Two gaps caused it. Hermes reports `Debugger.scriptParsed` with an empty `url` for scripts compiled from debug client expressions but never implemented `Debugger.getScriptSource`, so the follow-up request returned `-32601 Unsupported method`. The `dev-middleware` inspector proxy, meanwhile, intercepted every such request and tried to fetch the URL it had recorded for the script, failing closed on an empty or non-HTTP one. Hermes discards sources once compiled, so the CDP layer now retains the ones it compiles from debug client expressions. `Runtime.evaluate` and `Runtime.callFunctionOn` park their expression, and the Debugger domain coordinator attributes it to the script at load time, part way through the evaluation, so the source is available while paused on `debugger;`. Only the first script of an evaluation is attributed, so a nested `eval()` is not given the outer expression's source. `Debugger.getScriptSource` serves from that store and otherwise reports V8's `No script for id: <id>`. The proxy now forwards the request to the target when it has no HTTP(S) URL of its own to fetch. It still never reads local files. Changelog: [General][Fixed] - Fix "Unable to fetch script source" when debugging code evaluated in the DevTools console Differential Revision: D120358439
|
@vzaidman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D120358439. |
meta-codesync Bot
pushed a commit
to facebook/hermes
that referenced
this pull request
Sep 29, 2026
Summary: X-link: react/react-native#58559 Typing an expression into the DevTools console and then asking for its source failed with "Unable to fetch script source." Easiest repro: type `debugger;`, execution pauses, and the Sources panel has nothing to show. Two gaps caused it, one per layer; the inspector-proxy half is split into a separate diff stacked on top of this one. Hermes reports `Debugger.scriptParsed` with an empty `url` for scripts compiled from debug client expressions but never implemented `Debugger.getScriptSource`, so the follow-up request returned `-32601 Unsupported method`. Hermes discards sources once compiled, so the CDP layer now retains the ones it compiles from debug client expressions. `Runtime.evaluate` and `Runtime.callFunctionOn` park their expression, and the Debugger domain coordinator attributes it to the script at load time, part way through the evaluation, so the source is available while paused on `debugger;`. Only the first script of an evaluation is attributed, so a nested `eval()` is not given the outer expression's source. `Debugger.getScriptSource` serves from that store and otherwise reports V8's `No script for id: <id>`. Sources are kept in a capped map keyed by script ID, sharing each compilation's buffer instead of copying the expression twice. Follow-up D120383586 builds on this to serve expressions evaluated before the debugger attaches. Reviewed By: motiz88 Differential Revision: D120358439 fbshipit-source-id: b1484f6ca033a28de3e5e7a1625ca18fea0e8282
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Typing an expression into the DevTools console and then asking for its source
failed with "Unable to fetch script source." Easiest repro: type
debugger;,execution pauses, and the Sources panel has nothing to show.
Two gaps caused it. Hermes reports
Debugger.scriptParsedwith an emptyurlfor scripts compiled from debug client expressions but never implemented
Debugger.getScriptSource, so the follow-up request returned-32601 Unsupported method. Thedev-middlewareinspector proxy, meanwhile,intercepted every such request and tried to fetch the URL it had recorded for
the script, failing closed on an empty or non-HTTP one.
Hermes discards sources once compiled, so the CDP layer now retains the ones it
compiles from debug client expressions.
Runtime.evaluateandRuntime.callFunctionOnpark their expression, and the Debugger domaincoordinator attributes it to the script at load time, part way through the
evaluation, so the source is available while paused on
debugger;. Only thefirst script of an evaluation is attributed, so a nested
eval()is not giventhe outer expression's source.
Debugger.getScriptSourceserves from thatstore and otherwise reports V8's
No script for id: <id>.The proxy now forwards the request to the target when it has no HTTP(S) URL of
its own to fetch. It still never reads local files.
Changelog:
[General][Fixed] - Fix "Unable to fetch script source" when debugging code evaluated in the DevTools console
Differential Revision: D120358439