Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b6afe0d39e0af9268c13fae37454f093df55bd7a
      
https://github.com/WebKit/WebKit/commit/b6afe0d39e0af9268c13fae37454f093df55bd7a
  Author: Karl Dubost <[email protected]>
  Date:   2026-09-09 (Wed, 09 Sep 2026)

  Changed paths:
    A LayoutTests/js/dom/error-stack-data-url-truncation-expected.txt
    A LayoutTests/js/dom/error-stack-data-url-truncation.html
    M Source/JavaScriptCore/runtime/StackFrame.cpp

  Log Message:
  -----------
  Error.stack carries the whole script when the script came from a data: URL
https://bugs.webkit.org/show_bug.cgi?id=323636
rdar://186614179

Reviewed by Keith Miller, Abrar Rahman Protyasha, Yusuke Suzuki, and Darin 
Adler.

Reddit's startup script is a data: URL with the whole script inside it,
~65K of characters. A stack frame is one line of Error.stack with
multiple parts:

* the function name
* @
* where that function's code came from
*  :line:column.

That third part is the source URL. Normally it is short:
    mk@https://www.redditstatic.com/shreddit/bootstrap.js:1:38

But reddit does not load that script from a file. It pastes the script
into the page as a data: URL, a very long one.

When a tab loads in the background, reddit sends a report through Sentry
(version 6.12.0), which reads the stack to find the filename.

It tries three patterns on each line.
The first two only accept a line starting with "at ", which is what
Chrome writes, so JavaScriptCore's "fn@url" falls through to the third.

The 3rd pattern is trying to match for each individual character of
the long string something which looks like a filename. And it can't
find it. To go through the full it takes ~9 seconds or more. Sometimes
it tries multiple times.

Chrome matches on the first pattern which is under a millisecond.

Fix by truncating a data: URL to 1024 characters when writing the source
of a stack frame. We make sure to avoid percent escape so that the URL
stays parsable (%7B is {, cutting in the middle would make it not
decodable)

Sentry team for version 7.30.0 has done the same trick capping at 1024
characters to fix the same issue.

Ideally reddit would upgrade the Sentry version.

There is a new FIXME in the code for other schemes tracked in
https://webkit.org/b/323716

Test: js/dom/error-stack-data-url-truncation.html

* LayoutTests/js/dom/error-stack-data-url-truncation-expected.txt: Added.
* LayoutTests/js/dom/error-stack-data-url-truncation.html: Added.
* Source/JavaScriptCore/runtime/StackFrame.cpp:
(JSC::truncateLongDataURL):
(JSC::StackFrame::toString const):

Canonical link: https://commits.webkit.org/320770@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to