Skip to content

feat: parse JavaScript stack traces in the exception panel (HDX-5888) - #3534

Merged
kodiakhq[bot] merged 7 commits into
mainfrom
otel-browser-exception-stacks
Nov 4, 2026
Merged

kodiakhq[bot] merged 7 commits into
mainfrom
otel-browser-exception-stacks

Conversation

@SpencerTorres

Copy link
Copy Markdown
Member

Closes HDX-5888

Summary

Our new OTel JS SDKs send exception.stacktrace as raw text, so the exception panel showed a text block. This parses it into frames on webjs/nodejs rows and shows each Caused by: error as a collapsible section. Old parsed_stacktrace rows and other languages are unchanged. This is just a visual change to the exceptions panel.

Changes

  • Parser: Sentry's Chrome/Gecko line parsers, ported with the MIT notice. No new dependency.
  • Causes: collapsed one-line rows that expand to their own frames. Full message with line breaks when open. These get stacked (the SDK limits it to 5 by default)
  • Frames: library frames labeled "Library or framework code". No bare "in" on unnamed frames for when the parser/sourcemap can't find the parent func.

Screenshots

Before

Old SDK error for example (as seen in traces browser). As you can see this is undisturbed and the old SDK works fine.
old sdk error example

After

New Exceptions view panel (as seen on logs browser, where the SDKs send browser events)
new view overall

Raw stack trace (note the source maps used this data in the previous screenshot, and that caused by was parsed and separated)
raw stack trace

When source maps are unavailable:

example when source maps are unavailable

When there's no a stack trace, only a message:
example no stack trace

@SpencerTorres
SpencerTorres requested a review from a team as a code owner November 3, 2026 17:58
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 4, 2026 7:57pm UTC
hyperdx-storybook Ready Ready Preview Nov 4, 2026 7:57pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e139752

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the review/tier-3 Standard — full human review required label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🟡 Tier 3 — Standard

Introduces new logic, modifies core functionality, or touches areas with non-trivial risk.

Why this tier:

  • Diff size: 939 production lines changed (Tier 2 max: < 250)

Review process: Full human review — logic, architecture, edge cases.
SLA: First-pass feedback within 1 business day.

Stats
  • Production files changed: 6
  • Production lines changed: 939 (+ 943 in test files, excluded from tier calculation)
  • Branch: otel-browser-exception-stacks
  • Author: SpencerTorres

To override this classification, remove the review/tier-3 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 114 in total (1.39%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@SpencerTorres
SpencerTorres requested review from teeohhem and removed request for wrn14897 November 3, 2026 18:00
const MAX_PARSED_STACK_LENGTH = 64 * 1024;

const CAUSED_BY_REGEX = /^\s*Caused by: /;
const V8_FRAME_REGEX = /^\s*at /;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Message lines that start with "at " are read as V8 frames

V8_FRAME_REGEX = /^\s*at / also matches message lines with no indent. For example, new Error('Invalid cart\nat least one item required') makes getHeaderLength end the header at at least one item required. That cuts the line out of the cause title, and the very permissive chromeRegex (sentryStackParser.ts) turns it into a fake frame with filename least one item required. Real V8 frames are always indented ( at), so use /^\s+at / here, and require the same indent before handing lines to the Chrome parser.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

}) => {
const firstException = exceptionValues[0];

const shouldShowSourceMapFtux = useMemo(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — shouldShowSourceMapFtux was rewritten but nothing reads it

Its only other mention is the commented-out {/* {shouldShowSourceMapFtux && <SourceMapsFtux />} */}, so the memo runs on every render for nothing. The diff rewrote it for the new stacktrace union type anyway. Delete the memo and the comment, or wire it up properly.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

<span>{' in '}</span>
<span
style={{
background: '#ffffff10',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Function-name chip uses a hard-coded white tint that vanishes in light theme

The rewritten in <function> chip still uses background: '#ffffff10', which is invisible on a light background. Use a semantic token such as var(--color-bg-muted) or var(--color-bg-hover), as the semantic design tokens convention asks.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

4 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 4 minor

3 posted as inline comment(s) on the changed lines. 1 listed below.

Findings outside the changed lines

1 minor
  • 🔵 packages/app/src/components/ExceptionSubpanel.tsx:744 — Unparsed stack trace still uses a raw <pre>, against the REQUIRED code-snippet rule → The parsed path now shows the raw stack with CopySnippet, but the unparsed fallback in the new ExceptionValueSection still renders <pre className="px-4">. The "Code snippets (REQUIRED)" convention forbids raw <pre>. Render unparsedStack with CopySnippet too, so both paths look the same and both can be copied.

Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. This is a well-scoped, well-tested visual change. The parser runs only on webjs/nodejs rows with string exception.stacktrace, so old JSON parsed_stacktrace rows and other languages are provably untouched (verified by DBRowOverviewPanel.exception.test.tsx). Untrusted-input risk is bounded by explicit guards — 64 KB total cap, 1 KB per-line truncation, a >32-parentheses skip, and a 50-frame limit — and all stack text is rendered as React text, not HTML, so there is no injection surface. The notes below are recommendations and nits only.

🟡 P2 — recommended

  • packages/app/src/utils/sentryStackParser.ts:297 — Several new parser guard paths are not exercised: the 50-frame STACKTRACE_FRAME_LIMIT break is unreachable by the current fixtures (the only >50-frame case is >64 KB and short-circuits via MAX_PARSED_STACK_LENGTH before the parser runs), and the 1 KB per-line truncation, (error: …) webpack-wrapper stripping, and data: URI frame branches have no coverage.
    • Fix: Add javascriptStack.test.ts cases for a ~60-frame sub-64 KB stack asserting exactly 50 frames, an over-1024-char frame line, a webpack-wrapped frame, and a data: URI frame.
    • testing
🔵 P3 nitpicks (4)
  • packages/app/src/components/ExceptionSubpanel.tsx:682 — shouldShowSourceMapFtux is still computed but its only consumer is the commented-out JSX on line 721, and SourceMapsFtux is imported nowhere; the PR rewrote the memo body (to use getFrames) rather than removing dead code. Pre-existing.
    • Fix: Delete the shouldShowSourceMapFtux memo and the commented-out JSX, or wire up the FTUX if it is meant to ship.
    • maintainability, testing
  • packages/app/src/components/ExceptionSubpanel.tsx:437 — ExceptionValue.type is typed as required string but is built from any row attributes where it can be undefined; runtime is guarded by exception.type &&, so this is only a type-accuracy gap.
    • Fix: Type the field as type?: string to match what the producer actually provides.
  • packages/app/src/components/ExceptionSubpanel.tsx:1 — The file-wide /* eslint-disable @typescript-eslint/no-unused-vars */ suppresses exactly the lint that would flag the orphaned shouldShowSourceMapFtux during this refactor. Pre-existing.
    • Fix: Remove the blanket disable and scope suppressions to the specific intentional-underscore args.
  • packages/app/src/components/ExceptionSubpanel.tsx:631 — The mechanism.handled: true branch and the mechanism.data.{function,handler,target} labels are not covered; the only mechanism test uses {type:'onerror', handled:false}.
    • Fix: Add an ExceptionSubpanel case with handled: true and populated mechanism.data and assert each label/value renders.

Reviewers (6): correctness, adversarial, testing, maintainability, kieran-typescript, performance.

Testing gaps:

  • reverseFrames filename fallback (frame.filename || lastFrame.filename) is untested — no fixture produces an empty-filename frame.
  • Nested Gecko eval frames (… > eval line N > eval) and the getFirstFrame non-in_app fallback chain are only tested on the happy path.
  • The "Show N more frames" toggle and maxRows = Math.max(5, firstFrameIndex + 1) logic are uncovered — all fixtures have ≤2 frames, below the 5-row threshold.

Residual risk: The ported Sentry regexes run during render on client-controlled text; the 64 KB / 1 KB-per-line / 32-paren / 50-frame guards bound worst-case cost and the Sentry MIT + TraceKit provenance notices are complete and version-pinned, so this is noted rather than flagged.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 460 passed • 1 skipped • 1625s

Status Count
✅ Passed 460
❌ Failed 0
⚠️ Flaky 3
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@kodiakhq
kodiakhq Bot merged commit 04f55d1 into main Nov 4, 2026
28 checks passed
@kodiakhq
kodiakhq Bot deleted the otel-browser-exception-stacks branch November 4, 2026 20:04

This branch was successfully deployed

2 active deployments
Preview – hyperdx-storybook — e139752f Deployed Nov 4, 2026 by vercel[bot]
Preview – hyperdx-oss — e139752f Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants