Skip to content

feat(errors): JavaScript source maps: upload API, symbolicated issue stacks, grouping on mapped frames - #3020

Merged
Makisuo merged 17 commits into
mainfrom
sourcemaps/backend
Nov 24, 2026
Merged

Makisuo merged 17 commits into
mainfrom
sourcemaps/backend

feat(cli,browser): maple sourcemaps inject/upload and exception debug…

6b5fb2d
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review completed Nov 24, 2026 in 7m 26s

Confidence 6/10 · 1 issue to address

🟡 Confidence 6/10 · needs attention. Held at 6 because a correctness warning is open.
1 warning −1 · 1 note · tests partial −1 · risk high −1

Adds the client half of source maps: a Vite plugin that injects debug ids and moves maps out of the build, the Maple.SourceMaps upload provider, the prd-only upload key and browser debug-id stamping. Safe apart from a multi-environment wipe; the open apps/alerting/src/scheduled.ts errors are untouched.

  • mapleSourceMaps injects debug ids and relocates build maps behind a manifest
  • Maple.SourceMaps uploads them; the prd web deploy uploads maple-web's maps by release
  • Browser SDK stamps maple.exception.debug_ids from _mapleDebugIds and _sentryDebugIds

Before merge

Findings

🟠 Warning · F9 · A second processed environment wipes the first's maps from a shared mapsDir

correctness · packages/alchemy-maple/src/Vite.ts:105

closeBundle runs once per environment and each run calls relocateMaps with only that environment's output dirs, which first deletes every file the previous manifest listed (packages/sourcemaps/src/relocate.ts:75-84). With environments: ["client","server"] and an explicit mapsDir, the server run deletes the client's moved maps and the manifest lists only the server's, so half the build never symbolicates.

Collect every processed environment's output dirs and call `processBuildOutputs` once after the last `closeBundle`, or suffix an explicit `mapsDir` with the environment name.
🔵 Note · F10 · planMaps reads every map at once and holds all bodies through the upload

performance · packages/alchemy-maple/src/SourceMaps.ts:122

Effect.forEach over the manifest issues one unbounded fs.readFile per entry, and reconcile keeps every bytes alive while it hashes and uploads at concurrency 4, so a build with many chunks buffers its whole map set (hundreds of MiB) in the deploy process.

Bound the read concurrency (e.g. `{ concurrency: 4 }`) and read each map at upload time instead of planning every body up front.

Production impact

4 open error groups in the changed files, 130 occurrences. Details are in Maple.

Production traffic of the changed files (last 7 days)
File Calls/day
packages/alchemy-maple/src/MapleApi.ts 4.6k
packages/infra/src/secrets.ts 4.3k
apps/web/vite.config.ts 178
packages/alchemy-maple/src/Vite.ts 77
Telemetry this change adds and removes (27)
  • ➕ span name SourceMapReader.hasAny · packages/backend/src/services/sourcemaps/SourceMapReader.ts:67
  • ➕ span name SourceMapReader.findForFrames · packages/backend/src/services/sourcemaps/SourceMapReader.ts:80
  • ➕ attribute maple.source_map.frame_urls · packages/backend/src/services/sourcemaps/SourceMapReader.ts:86
  • ➕ attribute maple.source_map.matched · packages/backend/src/services/sourcemaps/SourceMapReader.ts:134
  • ➕ span name SourceMapReader.load · packages/backend/src/services/sourcemaps/SourceMapReader.ts:138
  • ➕ attribute maple.source_map.id · packages/backend/src/services/sourcemaps/SourceMapReader.ts:139
  • ➕ span name SourceMapReader.touch · packages/backend/src/services/sourcemaps/SourceMapReader.ts:146
  • ➕ span name SourceMapService.upload · packages/backend/src/services/sourcemaps/SourceMapService.ts:238
  • ➕ attribute maple.source_map.size_bytes · packages/backend/src/services/sourcemaps/SourceMapService.ts:244
  • ➕ attribute maple.source_map.has_debug_id · packages/backend/src/services/sourcemaps/SourceMapService.ts:252
  • ➕ span name SourceMapService.list · packages/backend/src/services/sourcemaps/SourceMapService.ts:333
  • ➕ span name SourceMapService.remove · packages/backend/src/services/sourcemaps/SourceMapService.ts:362
  • ➕ span name SourceMapService.sweepExpired · packages/backend/src/services/sourcemaps/SourceMapService.ts:389
  • ➕ attribute maple.source_map.swept · packages/backend/src/services/sourcemaps/SourceMapService.ts:391
  • ➕ span name SourceMapService.sweepOrphans · packages/backend/src/services/sourcemaps/SourceMapService.ts:395
  • ➕ attribute maple.source_map.orphans_swept · packages/backend/src/services/sourcemaps/SourceMapService.ts:397
  • ➕ span name SourceMapRetention.tick · packages/backend/src/services/sourcemaps/SourceMapService.ts:431
  • ➕ span name StackSymbolicator.sourceMapsKnown · packages/backend/src/services/sourcemaps/StackSymbolicator.ts:108
  • ➕ span name StackSymbolicator.symbolicate · packages/backend/src/services/sourcemaps/StackSymbolicator.ts:302
  • ➕ attribute maple.stack.frames · packages/backend/src/services/sourcemaps/StackSymbolicator.ts:315
  • ➕ attribute maple.stack.js_urls · packages/backend/src/services/sourcemaps/StackSymbolicator.ts:316
  • ➕ attribute maple.stack.status · packages/backend/src/services/sourcemaps/StackSymbolicator.ts:319
  • ➕ attribute maple.stack.org_has_maps · packages/backend/src/services/sourcemaps/StackSymbolicator.ts:330
  • ➕ attribute maple.stack.lookup_failed · packages/backend/src/services/sourcemaps/StackSymbolicator.ts:367
  • ➕ attribute maple.stack.resolved_frames · packages/backend/src/services/sourcemaps/StackSymbolicator.ts:473
  • ➕ attribute maple.stack.maps_matched · packages/backend/src/services/sourcemaps/StackSymbolicator.ts:475
  • ➕ span name SourceMapFiles.validateUpload · packages/backend/src/services/sourcemaps/source-map-files.ts:122
What was checked
  • The CLI sends the key as a bearer token and sets redirect: "manual" (apps/cli/src/core/sourcemaps-upload.ts:82,86)
  • vite.config.ts:148 and alchemy.run.ts:441 resolve to the same maps directory
  • webSourceMapsApiKey is prd-only, consumer web, with its grants row (secret-grants.test.ts:104)

6b5fb2d · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

Annotations

Check warning on line 105 in packages/alchemy-maple/src/Vite.ts

See this annotation in the file changed.

@maple-review-bot maple-review-bot / Maple / review

correctness: A second processed environment wipes the first's maps from a shared `mapsDir`

`closeBundle` runs once per environment and each run calls `relocateMaps` with only that environment's output dirs, which first deletes every file the previous manifest listed (`packages/sourcemaps/src/relocate.ts:75-84`). With `environments: ["client","server"]` and an explicit `mapsDir`, the server run deletes the client's moved maps and the manifest lists only the server's, so half the build never symbolicates.

Check notice on line 122 in packages/alchemy-maple/src/SourceMaps.ts

See this annotation in the file changed.

@maple-review-bot maple-review-bot / Maple / review

performance: `planMaps` reads every map at once and holds all bodies through the upload

`Effect.forEach` over the manifest issues one unbounded `fs.readFile` per entry, and `reconcile` keeps every `bytes` alive while it hashes and uploads at concurrency 4, so a build with many chunks buffers its whole map set (hundreds of MiB) in the deploy process.