Closed Bug 1587839 Opened 6 years ago Closed 6 years ago

Stacks for console.error stacks don't link to original locations

Categories

(DevTools :: Console, defect, P2)

defect

Tracking

(firefox71 verified)

VERIFIED FIXED
Firefox 71
Tracking Status
firefox71 --- verified

People

(Reporter: Harald, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

STR:

AR: Opens bundle.js in Debugger

ER: Open app.jsx

The sourcemap service does not pass the sourceId of the mapped source when calling the subscribe callback, which means we are re-using the one from the original frame (and then the debugger open the source for that sourceId, i.e. the bundle).

The following patch seems to make it work:

diff --git a/devtools/client/framework/source-map-url-service.js b/devtools/client/framework/source-map-url-service.js
--- a/devtools/client/framework/source-map-url-service.js
+++ b/devtools/client/framework/source-map-url-service.js
@@ -321,10 +321,10 @@ SourceMapURLService.prototype._callOneCa
 
   const resolvedLocation = await subscriptionEntry.promise;
   if (resolvedLocation) {
-    const { line, column, sourceUrl } = resolvedLocation;
+    const { line, column, sourceUrl, sourceId } = resolvedLocation;
     // In case we're racing a pref change, pass the current value
     // here, not plain "true".
-    callback(this._prefValue, sourceUrl, line, column);
+    callback(this._prefValue, sourceUrl, line, column, sourceId);
   }
 };
 
diff --git a/devtools/client/shared/components/SmartTrace.js b/devtools/client/shared/components/SmartTrace.js
--- a/devtools/client/shared/components/SmartTrace.js
+++ b/devtools/client/shared/components/SmartTrace.js
@@ -73,12 +73,19 @@ class SmartTrace extends Component {
           new Promise(resolve => {
             const { lineNumber, columnNumber, filename } = frame;
             const source = filename.split(" -> ").pop();
-            const subscribeCallback = (isSourceMapped, url, line, column) => {
+            const subscribeCallback = (
+              isSourceMapped,
+              url,
+              line,
+              column,
+              sourceId
+            ) => {
               this.onSourceMapServiceChange(
                 isSourceMapped,
                 url,
                 line,
                 column,
+                sourceId,
                 index
               );
               resolve();
@@ -171,6 +178,7 @@ class SmartTrace extends Component {
     filename,
     lineNumber,
     columnNumber,
+    sourceId,
     index
   ) {
     if (isSourceMapped) {
@@ -180,7 +188,7 @@ class SmartTrace extends Component {
 
       this.setState(state => {
         const stacktrace = (state && state.stacktrace) || this.props.stacktrace;
@@ -189,6 +197,7 @@ class SmartTrace extends Component {
             filename,
             lineNumber,
             columnNumber,
+            sourceId,
           })
           .concat(stacktrace.slice(index + 1));

We probably need to update all the callbacks through the toolbox to make sure we pass the sourceId around.

What's strange is the sourceId doesn't seem to be used. So far as I've seen, viewSourceInDebugger doesn't find an actor with the mapped source ID, and falls back to https://searchfox.org/mozilla-central/source/devtools/client/shared/view-source.js#80. But any other non-existent sourceId works equally well.

The sourceId is then used in the various places where we call the sourcemap service.
A test is added in the console to make sure that we do navigate to the mapped
location in the debugger.

Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/76a5311b6445 Pass the sourceId to sourcemap service subscribe callback. r=loganfsmyth.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 71
Assignee: nobody → nchevobbe
Regressions: 1589346

This revert the changes made in Bug 1587839, except the added test.
The safer fix to be uplifted is to only fix the original issue
in the SmartTrace component, where we remove any sourceId we might
have when creating the new mapped frame.

We also modify the browser_dbg-pretty-print-console test to ensure
clicking on a prettified location in the console does open the
debugger with the expected location.

Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fac6219649be Fix navigation to debugger from console on prettified sources. r=loganfsmyth.

It just occured to me that this was meant to be the patch for Bug 1589346 :/
Is there anything we can do to correct that? (the new patch need to be uplifted, and I'm afraid the bug number will be confusing?)

Flags: needinfo?(dluca)

Backed out changeset fac6219649be (Bug 1587839) on request by nchevobbe, per comment 9

Flags: needinfo?(dluca)
Backout by dvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b211b2e4f378 Backed out changeset fac6219649be on request by nchevobbe DONTBUILD

Comment on attachment 9103471 [details]
Bug 1587839 - Fix navigation to debugger from console on prettified sources. r=loganfsmyth.

Revision D50173 was moved to bug 1589346. Setting attachment 9103471 [details] to obsolete.

Attachment #9103471 - Attachment is obsolete: true
Flags: qe-verify+

I have managed to reproduce the issue using Ubuntu 18.04 LTS x64 on Fx nightly 71.0a1 (2019-10-17), I can confirm that the issue is fixed on all OS platforms using the latest beta version.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: