Closed Bug 1932023 Opened 4 months ago Closed 2 months ago

Debugger pretty print can fail on files using windows line breaks

Categories

(DevTools :: Debugger, defect, P2)

Desktop
All
defect

Tracking

(firefox136 verified)

VERIFIED FIXED
136 Branch
Tracking Status
firefox136 --- verified

People

(Reporter: jrmuizel, Assigned: jdescottes)

References

(Blocks 2 open bugs, Regressed 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

STR:

I get:

Error loading this URI: Unterminated string constant (1:25)
Stack in the worker:requireAcorn/</pp$4.raise@resource://devtools/client/debugger/dist/pretty-print-worker.js:7206:21
requireAcorn/</pp.readString@resource://devtools/client/debugger/dist/pretty-print-worker.js:9042:55
requireAcorn/</pp.getTokenFromCode@resource://devtools/client/debugger/dist/pretty-print-worker.js:8837:25
requireAcorn/</pp.readToken@resource://devtools/client/debugger/dist/pretty-print-worker.js:8561:23
requireAcorn/</pp.nextToken@resource://devtools/client/debugger/dist/pretty-print-worker.js:8552:23
requireAcorn/</pp.next@resource://devtools/client/debugger/dist/pretty-print-worker.js:8513:16
requireAcorn/</pp.getToken@resource://devtools/client/debugger/dist/pretty-print-worker.js:8517:16
#getTokens@resource://devtools/client/debugger/dist/pretty-print-worker.js:9752:29
getPrettifiedCodeAndSourceMap@resource://devtools/client/debugger/dist/pretty-print-worker.js:9580:43
prettyFast@resource://devtools/client/debugger/dist/pretty-print-worker.js:9366:38
prettyPrintInlineScript@resource://devtools/client/debugger/dist/pretty-print-worker.js:10617:34
requireWorkerUtils/workerHandler/</<@resource://devtools/client/debugger/dist/pretty-print-worker.js:3691:58
requireWorkerUtils/workerHandler/<@resource://devtools/client/debugger/dist/pretty-print-worker.js:3689:19

Breaks the editor, P2

Severity: -- → S3
Priority: -- → P2

Another occurence on https://rosasthai.com/locations against locations HTML file, which seems to reproduce more consistantly.

(In reply to Alexandre Poirot [:ochameau] from comment #2)

Another occurence on https://rosasthai.com/locations against locations HTML file, which seems to reproduce more consistantly.

Looks like the index contains several scripts, and for the second one we get the wrong indices and try to prettify the following string:

>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-P4ML2

Edit: Interestingly this doesn't reproduce by simply reusing the exact same HTML

I think it's because some line breaks are \r\n instead of \n

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Summary: https://unsplash.com/s/photos/renaissance doesn't unminify → Debugger pretty print can fail on files using windows line breaks

(not getting the issue anymore for https://unsplash.com/s/photos/renaissance)

Depends on D234020
In case of pretty printing error, we display the error from the worker, from the action dispatcher.
We could log the source which failed to be pretty printed, especially for html inline scripts where
several small scripts will be prettified independantly.

Blocks: 1942009

Comment on attachment 9459386 [details]
Bug 1932023 - [devtools] Log error message when pretty print fails to handle a script

Revision D234172 was moved to bug 1942009. Setting attachment 9459386 [details] to obsolete.

Attachment #9459386 - Attachment is obsolete: true
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7987a688d02b [devtools] Fix pretty print issues with files containing windows line breaks r=devtools-reviewers,ochameau
Regressions: 1942027
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 136 Branch

I can reproduce this issue before the fix in Nightly v136.0a1 (2025-01-15) and unfortunately, I can still reproduce it after the fix in Nightly v136.0a1 (2025-01-17) (64-bit) and Nightly v137.0a1 (2025-02-12), however, this issue is not reproducible in the latest Beta v136.0b5 or Release v135.0.
In conclusion, this issue only reproduces in Nightly channel and the fix does not resolve the original issue.

Julian, can you take a look? Do you know what's wrong?

Flags: needinfo?(jdescottes)

(In reply to Daniel Bodea [:danibodea] from comment #11)

I can reproduce this issue before the fix in Nightly v136.0a1 (2025-01-15) and unfortunately, I can still reproduce it after the fix in Nightly v136.0a1 (2025-01-17) (64-bit) and Nightly v137.0a1 (2025-02-12), however, this issue is not reproducible in the latest Beta v136.0b5 or Release v135.0.
In conclusion, this issue only reproduces in Nightly channel and the fix does not resolve the original issue.

Julian, can you take a look? Do you know what's wrong?

Thanks for the ping!

Looks like a slightly different bug, which only occurs when devtools.debugger.features.codemirror-next is true (which is Nightly only).
I was probably testing with devtools.debugger.features.codemirror-next set to false? Or something changed on the website. Will take a look!

So the patch actually fixes the following STRs, normally consistently regardless of codemirror versions:

ER: should work
AR (before patch): breaks with Unterminated string constant (5:40)

For the initial test page ( https://unsplash.com/s/photos/renaissance), I don't actually think it's purely related to the codemirror version.
When testing I get a very inconsistent behavior, sometimes it fails, sometimes it succeeds and I haven't exactly pinned down consistent STRs. But I get the error in all versions of Firefox available at the moment (135 to 137)

So I would suggest we close this, as the patch still fixes the alternative STRs, and I will file another bug for https://unsplash.com/s/photos/renaissance.

Flags: needinfo?(jdescottes)
Blocks: 1947854

I managed to reproduce the issue using the steps in comment 13 in Windows 10, MacOS 11 and MacOS 14 aarch64 with Nightly v136.0a1 from 2024-01-15. The issue is more likely to reproduce in low-end machines, but closing the tab and reloading the page, causes the issue to reproduce with a higher repro rate. I can confirm the fix in Nightly v136.0a1 from 2025-01-17 and Nightly v136.0a1 from 2025-02-13.

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

Attachment

General

Created:
Updated:
Size: