Skip to content

Source maps phase 4: stack symbolication - #124

Merged
unjica merged 2 commits into
feature/source-maps-phase3from
feature/source-maps-phase4
Jul 2, 2026
Merged

unjica merged 2 commits into
feature/source-maps-phase3from
feature/source-maps-phase4

Conversation

@unjica

@unjica unjica commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add stack-symbolicate.ts — parse V8/Firefox stack lines, match frames to uploaded maps by (project, app, release, bundle_url), resolve via @jridgewell/trace-mapping
  • GET /api/errors/:id returns optional symbolicated_top_stack and per-occurrence symbolicated_stack when maps exist for the release
  • Bundle URL matching requires same origin for full URLs (avoids false matches on shared basenames across CDNs)
  • Unit tests + docs/CHANGELOG updates

Stacked on #122 (phase 3). Merge phase 3 first, then this PR (retarget base to develop after #122 lands).

Part of #98 (v1.3.0). No new migrations.

Test plan

  • pnpm --filter api exec vitest run src/lib/stack-symbolicate.test.ts
  • pnpm run build
  • Upload a map via phase 3 API, ingest an error with matching release + stack URL, confirm symbolicated_stack on error detail

Made with Cursor

Comment thread apps/api/src/lib/stack-symbolicate.ts Resolved
Comment thread apps/api/src/lib/stack-symbolicate.ts Resolved
@unjica
unjica force-pushed the feature/source-maps-phase4 branch from 23578f6 to e6b79e4 Compare July 2, 2026 12:04
}
return { ...occ, symbolicated_stack: symbolicated };
})
);

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.

Top stack frame race

Medium Severity

symbolicated_top_stack is filled inside concurrent Promise.all workers via a shared symbolicatedTop flag, so whichever occurrence finishes first after awaiting maps can win—not necessarily the newest row. Docs require the first symbolicated frame from the newest occurrence stack only, and when that stack does not resolve the field should stay unset rather than falling back to an older occurrence.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c729d7f. Configure here.

@unjica
unjica force-pushed the feature/source-maps-phase4 branch from c729d7f to bf3e3a9 Compare July 2, 2026 12:11

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bf3e3a9. Configure here.

}
}

if (frame.endsWith(bundle) || bundle.endsWith(frame)) return true;

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.

Cross-host match relative bundle URL

Medium Severity

When an artifact’s bundle_url has no scheme (e.g. app.js), frameMatchesBundle can match a full https://…/app.js frame via frame.endsWith(bundle) without comparing origins, contradicting the PR’s goal of avoiding basename matches across CDNs when the frame is an absolute URL.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bf3e3a9. Configure here.

return (
frameUrl.pathname === bundleUrlObj.pathname ||
frameUrl.pathname.endsWith(bundleUrlObj.pathname)
);

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.

Same-origin suffix map mismatch

Low Severity

For two absolute URLs on the same origin, frameMatchesBundle treats frameUrl.pathname.endsWith(bundleUrlObj.pathname) as a match, so a frame under /long/path/app.js can bind to an artifact registered for /app.js and use the wrong map.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bf3e3a9. Configure here.

unjica and others added 2 commits July 2, 2026 14:13
Parse V8 and Firefox stack frames, resolve positions with uploaded source maps, and expose symbolicated_stack fields on GET /api/errors/:id for display-only de-minification.

Co-authored-by: Cursor <[email protected]>
Derive symbolicated_top_stack from the first resolvable frame in occurrence stacks instead of top_stack (error message line), and dedupe concurrent listSourceMapArtifactsForRelease calls per release.

Co-authored-by: Cursor <[email protected]>
@unjica
unjica force-pushed the feature/source-maps-phase4 branch from bf3e3a9 to b2dd996 Compare July 2, 2026 12:13
@unjica
unjica merged commit 44063e2 into feature/source-maps-phase3 Jul 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant