Skip to content

Browser stack parser gets confused by '(' in function names #26205

Open

Description

@medmunds

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

11.11.0 (@sentry/browser, @sentry/wasm); 5.4.1 (@sentry/vite-plugin)

Framework Version

No response

Link to Sentry event

https://medmunds.sentry.io/issues/7834537385/events/147e4b1014e14ded8a52603555cab96a/

Reproduction Example/SDK Setup

Init:

Steps to Reproduce

  1. Create a JS app with a function that includes ( in the name. E.g., methodCaller< (emscripten::val) => void>, which is the actual name of an Emscripten-generated wasm-to-JS bridge function.

    Note that Emscripten with -sDYNAMIC_EXECUTION=0 generates these methodCaller bridge functions and sets their names to show the full C method signature.

    For testing purposes, you can skip the whole Emscripten/wasm toolchain and just mimic what Emscripten does:

    function methodCaller(val) {
      throw new Error("test error");
    }
    Object.defineProperty(methodCaller, "name", { value: "methodCaller< (emscripten::val) => void>" });
  2. Build your app and upload sourcemaps to Sentry. (I'm using @sentry/vite-plugin, but I don't think it's relevant to the issue.)

  3. Cause an exception to be logged while that function is on the stack.

  4. Examine the recorded stack trace in Sentry.

Here's an actual raw stack trace that Sentry has trouble parsing. Note the methodCaller frame:

TypeError: Cannot create property 'imageData' on boolean 'false'
    at Drawing.blitterFree (../src/puzzle/drawing.ts:273:13)
    at methodCaller< (emscripten::val) => void> (https://puzzles.twistymaze.com/assets/worker-BBxJRpa6.js:1:43074)
    at wasmImports._emval_invoke (../src/assets/puzzles/emcc-runtime.js:1:52388)
  inertia-BCZY8y8t.wasm0x2299c      null (/assets/inertia-BCZY8y8t.wasm)
  inertia-BCZY8y8t.wasm0x194cc      null (/assets/inertia-BCZY8y8t.wasm)
  inertia-BCZY8y8t.wasm0x1bfd1      null (/assets/inertia-BCZY8y8t.wasm)
  inertia-BCZY8y8t.wasm0x13ad6      null (/assets/inertia-BCZY8y8t.wasm)
  inertia-BCZY8y8t.wasm0x21703      null (/assets/inertia-BCZY8y8t.wasm)
  inertia-BCZY8y8t.wasm0x216b4      null (/assets/inertia-BCZY8y8t.wasm)
    at Frontend.size (../src/assets/puzzles/emcc-runtime.js:1:21293)
    at WorkerPuzzle.size (../src/puzzle/worker.ts:241:26)
    at callback (../node_modules/.pnpm/comlink@4.4.2/node_modules/comlink/dist/esm/comlink.mjs:103:48)

Expected Result

Sentry should be able to parse the correct filename from the stack trace (https://puzzles.twistymaze.com/assets/worker-BBxJRpa6.js in the trace above example above).

And Sentry should be able to link the stack frame back to the uploaded sourcemap by debug id.

Actual Result

Sentry incorrectly parses the filename as everything between the outermost (...) on a stack frame line. (In the example above, it thinks the filename/uri is emscripten::val) => void> (https://puzzles.twistymaze.com/assets/worker-BBxJRpa6.js.)

Image Image

Additional Context

#26202 is essentially the same issue in @sentry/node. This part of stack parsing is not shared between @sentry/browser and @sentry/node, so I've opened this as a separate issue against @sentry/browser.

The example event here originated in Chrome Mobile WebView 150.0.7871 Android 13, but the stack parsers for all browsers should be reviewed as they seem to use similar regex captures.

(If there is other textual stack trace parsing elsewhere in Sentry, it would be a good idea to review it for similar problems on any platforms where displayed function names can be set to arbitrary strings.)

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions