Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0a74c1b
feat(bundler-plugin-core): verify the debug-ID stamp, and delete maps…
krassx Nov 23, 2026
7f13da8
feat(bundler-plugin-core): stamp debug-IDs inside the build for Vite,…
krassx Nov 23, 2026
de212ad
docs: in-build stamping, stamp verification and safe map deletion
krassx Nov 23, 2026
d251091
chore: changeset for in-build stamping
krassx Nov 23, 2026
e8495dd
fix(bundler-plugin-core): review findings on in-build stamping
krassx Nov 23, 2026
d42fe8f
fix(bundler-plugin-core): round-2 review findings on stamp verification
krassx Nov 23, 2026
780fd61
fix(bundler-plugin-core): round-3 review findings
krassx Nov 23, 2026
707bcf7
fix(bundler-plugin-core): upload a pre-stamped build as an explicit f…
krassx Nov 23, 2026
2e4885f
fix(bundler-plugin-core): upload and delete every uploadable map, wha…
krassx Nov 23, 2026
e7a6f10
fix(bundler-plugin-core): delete stylesheet/declaration maps on the p…
krassx Nov 23, 2026
6d06b43
fix(bundler-plugin-core): stamp moved maps, walk any depth, determini…
krassx Nov 23, 2026
3bdb914
fix(bundler-plugin-core): foreign maps survive, unreachable maps are …
krassx Nov 23, 2026
4cb9575
fix(bundler-plugin-core): delete by identity (what this build emitted…
krassx Nov 23, 2026
21daacb
fix(bundler-plugin-core): webpack/Rspack asset names with a ?query no…
krassx Nov 23, 2026
10242b1
fix(bundler-plugin-core): cut asset names at '?' only; '#' is part of…
krassx Nov 23, 2026
4077365
chore(bundler-plugin-core): round-12 leftovers (limits doc, script-li…
krassx Nov 23, 2026
d8570ff
fix(bundler-plugin-core): write webpack/Rspack stamped assets as STRI…
krassx Nov 23, 2026
3782b60
fix(bundler-plugin-core): Vite workers keep the debug-id in their map…
krassx Nov 23, 2026
837bd6c
fix(bundler-plugin-core): the worker catch-up never costs the build i…
krassx Nov 23, 2026
9f67602
fix(bundler-plugin-core): catch-up always verifies/restores, reports …
krassx Nov 23, 2026
8c798c5
test(bundler-plugin-core): pin the catch-up's per-pair read guard
krassx Nov 23, 2026
355d236
fix(bundler-plugin-core): address PR #221 review threads and code-sca…
krassx Nov 23, 2026
436ac98
test(bundler-plugin-core): type the catch-up edge-case run mock
krassx Nov 23, 2026
a67491a
style(bundler-plugin-core): format a test
krassx Nov 23, 2026
048700a
fix(bundler-plugin-core): on-disk re-check judges only what the stamp…
krassx Nov 23, 2026
e0d192d
fix(bundler-plugin-core): report an unrestorable rewrite, sibling out…
krassx Nov 23, 2026
c4bf2ff
fix(bundler-plugin-core): a generate()-only output cannot hide anothe…
krassx Nov 23, 2026
97da0be
fix(bundler-plugin-core): coordinate outputs by physical directory; s…
krassx Nov 23, 2026
117053e
fix(bundler-plugin-core): generate()-only outputs are no siblings; ca…
krassx Nov 23, 2026
0f9a3ef
feat(nextjs): withBugsee() source-map upload for webpack and Turbopac…
krassx Nov 23, 2026
0d360f9
fix(bundler-plugin-core): review sweep - own-map exception by own nam…
krassx Nov 23, 2026
5fbeb79
Merge origin/feat/in-build-stamping (#224) into the sweep
krassx Nov 23, 2026
3bbcbce
fix(nextjs,bundler-plugin-core): remove forced browser maps when the …
krassx Nov 23, 2026
e04f684
docs(nextjs): registration follows the source-map pipeline; document …
krassx Nov 23, 2026
f5455e3
fix(nextjs): sweep forced browser maps after every run, and when a se…
krassx Nov 23, 2026
dd5b68c
fix(bundler-plugin-core): address PR review (generate-only, standalon…
krassx Nov 24, 2026
4b39207
fix(bundler-plugin-core): webpack stamps in-build in every mode; only…
krassx Nov 24, 2026
db8d182
fix(bundler-plugin-core,nextjs): review round on in-build stamping (s…
krassx Nov 24, 2026
9cea1b1
fix(nextjs): honour deleteMaps:false and sweep forced maps on the no-…
krassx Nov 24, 2026
71a2ea6
docs(source-maps): webpack forced-map sweep honours deleteMaps:false …
krassx Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/in-build-stamping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bugsee/bundler-plugin-core': patch
---

Vite, Rollup and Rspack now stamp debug-IDs INSIDE the build (Vite/Rollup in `generateBundle`, `order: 'pre'`; Rspack at `PROCESS_ASSETS_STAGE_DEV_TOOLING + 1`, as webpack 5 already did), so Subresource Integrity hashes taken later describe the stamped bytes and a page that pins them keeps loading, with its maps uploaded. List the Bugsee plugin before any SRI plugin. A failed or impossible in-build stamp (an older Rollup, `sourcemap: 'inline'`) falls back to stamping after emit, where the SRI refusal still applies; esbuild and the standalone CLI stay post-emit. Every stamp is now verified (each bundle still parses, its sourceMappingURL is intact, the bytes are the original plus the appended stamp, and the map carries the bundle's debugId; a failure leaves or restores the original bytes and is reported), an in-build stamp is re-checked on disk and against the page's integrity pins, and `.map` files are deleted only after a confirmed upload and only when they carry a debugId. Adds `acorn` as a dependency for the parse check.
6 changes: 6 additions & 0 deletions .changeset/nextjs-with-bugsee.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@bugsee/nextjs': minor
'@bugsee/bundler-plugin-core': minor
---

`@bugsee/nextjs/config` adds `withBugsee(nextConfig, options)`: `next build` now stamps debug-IDs and uploads source maps on both webpack and Turbopack (Next 15.4.0+ for Turbopack, through `compiler.runAfterProductionCompile`). Browser maps are deleted after a confirmed upload; server and edge maps are kept. `@bugsee/bundler-plugin-core` exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv` and `mergeBuildPluginEnv` for it.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ reports/
# `biome check .` by the thousand.
.next/

# Fixture apps the Next source-map e2e generates and builds (packages/nextjs-e2e/test/source-maps.e2e.ts).
packages/nextjs-e2e/.fixtures/
packages/nextjs-e2e/.scratch/

# tsup writes a bundled config next to the package when tsup.config.ts needs transpiling, and leaves
# it behind if the build is interrupted. Untracked, it fails `biome check .` on a formatting rule.
tsup.config.bundled_*.mjs
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Runnable SDKs exist for **Node, Browser, Bun, Electron, Cloudflare/Vercel edge,
- Electron platform: `@bugsee/electron` (`docs/design/electron.md`, slices E0–E8, convergent-reviewed) — converges main (Node/`@bugsee/node`) + renderers (Chromium/`@bugsee/browser`) + native (`crashReporter` minidumps) into ONE session. Main OWNS the session; renderers stream capture UP over IPC (reusing the WebView **streaming CaptureStore** core, extracted to `@bugsee/core`) and are driven DOWN via a control channel (session handshake + pause/resume/flush/stop). Native crashes via Electron's built-in `crashReporter` (Crashpad), session-correlated `extra` (no bespoke native SDK). Visual capture D8: **rrweb DOM-replay is the DEFAULT** (rides the renderer streaming path free); **opt-in pixel video** (`video:{source}`) is a permission-gated report-time snapshot source (added the mobile-canonical `video` FileType + a generic node `reportSnapshots`/`fileEncoders` forwarding seam) supporting capturePage + MediaRecorder. Entries: `.`/`./main`/`./renderer`/`./preload`. `electron`/DOM taken as injected args — the package has **no electron/DOM dependency**.
- Extensions / umbrella: `@bugsee/performance` (APM — web-vitals + metric catalog, on-by-default via the umbrella) and `@bugsee/bugsee` (umbrella, with per-runtime browser/node `exports` conditions).
- E2E: `@bugsee/instrumentation-tests` — boots the REAL SDK in real node/bun processes against a mock collector and asserts the uploaded bundle (`pnpm test:e2e`; not in `pnpm test`).
- Build integration (source maps): **`@bugsee/nextjs/config`** `withBugsee()` — webpack (per-compilation plugin) AND Turbopack (`compiler.runAfterProductionCompile`) upload, real-Next e2e in `@bugsee/nextjs-e2e` (`docs/design/source-maps.md` §7.3).
- Framework adapters: the **per-request context foundation** (portable `RequestContext` + `ContextProvider` in core; `AsyncLocalStorage` binding in node, with `run` + `enterWith`; **correlation-by-tagging** — entries stamped with `contextId`/trace, reports merge the active context) + **`@bugsee/express`** (`requestHandler`/`errorHandler`/`setupExpress`) + **`@bugsee/fastify`** (hook-based `setupFastify`) + **`@bugsee/nestjs`** (`setupNest`: `enterWith` context middleware + a configurable error seam — default non-intrusive interceptor, opt-in global ExceptionFilter or `both` deduped; real-Nest e2e on express+fastify) + **`@bugsee/hono`/`elysia`/`hapi`/`koa`** (each structural-peer, per-framework error-capture probed before building; real-framework e2e) are built. (Restify was built then dropped — unmaintained, doesn't import on Node ≥18.) Plus **incoming-server auto-instrumentation** (`docs/design/incoming-server-instrumentation.md`): a **shared server-instrument core in `@bugsee/node`** (`server-instrument.ts` — plain values → `ServerRequestSpan`; `runServerRequest`/`openServerRequest`/split `openServerContext`+`startServerSpan`/`getActiveServerSpan`; **first-owner-wins re-entrancy** = one context + one `http.server` txn even when the http layer AND an adapter both run; only a `run`-scoped owner is refinable) auto-instruments incoming requests via the **`node:http` `Server.prototype.emit` patch** + native **`Bun.serve`** wraps, **ON BY DEFAULT** (`instrumentIncomingRequests`, default `true`; `false` opts out). **All 7 adapters were refactored onto this core** (each keeps its own `shouldReport`/route extraction). `@bugsee/server-adapters` was **retired** (engine absorbed; `openBugsee*`→`server*`). See `docs/design/framework-adapters.md` + `docs/design/incoming-server-instrumentation.md` (`generic-server-adapter.md` is superseded).
- `launch(appToken, options)` returns the started client (every platform).

Expand Down
6 changes: 6 additions & 0 deletions docs/PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1528,3 +1528,9 @@ Verified against current majors, all green with no adapter code changes: `@bugse
`launch(undefined)` on Node/Bun died with an opaque `TypeError ... reading 'length'` inside `hashAppToken`, crashing the host at startup. Every runtime composition root (`@bugsee/node` + bun, `@bugsee/electron` `launchMain`/`launchRenderer` (guard before any wiring; a bad-token renderer sends no hello and takes no page slot), `@bugsee/browser` + umbrella/electron-renderer, `@bugsee/vercel-edge` + cloudflare, `@bugsee/webworker`) now calls the shared `createDisabledClientForMissingToken` (`@bugsee/core` `app-token.ts`) first: a missing / empty / whitespace-only / non-string token reports ONE `Bugsee: the app token is missing ...` error through `onError` (else `console.warn`) and returns a DISABLED client (never started, `launch()` is a no-op, claims no carrier slot, so a later valid launch works; the browser one resolves it, `showReportDialog()` resolves `null`). `@bugsee/webview` is untouched (the native host owns the token; the JS side never uses it on the wire). Tests: `app-token.test.ts` + `launch-missing-token.test.ts` per entry.

**Follow-up 2 (issue #11).** `sveltekit-e2e` now wires `sveltekit({ preprocess: [componentAnnotatePreprocessor()] })` (the `@bugsee/sveltekit` README Kit 3 call, with the plugin imported by path) and asserts the SSR HTML carries `data-bugsee-component` (mutation-checked: removing `preprocess` fails it). The plugin is imported from its built dist (the e2e builds it first) because Kit 3 re-loads `vite.config.ts` in a plain-Node post-build process that cannot resolve the workspace's extensionless TS source. The README nits were already fixed (#157). Only Rollup 5 (still prerelease, `5.0.0-2` on the `beta` tag) remains open: keep watching.

### Debug-ID stamping inside the build for Vite, Rollup and Rspack; verified stamps; safe map deletion (2026-11-23)
`@bugsee/bundler-plugin-core` now stamps INSIDE the build wherever the bundler has a pre-write hook, so Subresource Integrity hashes taken later describe the stamped bytes: webpack 5 and **Rspack** at `PROCESS_ASSETS_STAGE_DEV_TOOLING + 1` (shared `tapProcessAssetsStamp`), **Vite and Rollup** in `generateBundle` (`order: 'pre'`; `rollupAssetStore` over chunks + `.map` assets; the stamped id is also put on `chunk.map` because Vite regenerates the map of a lazy-loading chunk after user hooks). esbuild and the standalone CLI stay post-emit with the SRI refusal (its message now names the workaround). Every stamp is verified (`verify-stamp.ts`: parses, sourceMappingURL intact, map debugId matches, original bytes + appended stamp): in-build all-or-nothing, post-emit snapshot + restore of the failing pair (`stamp-files.ts`); an in-build stamp is re-checked on disk (`verifyStampedPairs`) and against the HTML (`findIntegrityMismatches`). `.map` deletion now requires a confirmed upload AND a debugId on the map (`partitionByKeyed`). Real-build proof: `plugin.in-build.real-build.test.ts` (Vite 7 + 8, Rollup, Rspack with its built-in SRI plugin) and a Chromium run in `instrumentation-tests/test/sri-vite-rollup.e2e.ts`. Measured ordering limits and what the guards do not see: `docs/design/source-maps.md` §7.1.

### Next.js build integration: `withBugsee` (`@bugsee/nextjs/config`), webpack AND Turbopack (2026-11-23)
`withBugsee(nextConfig, options)` makes `next build` stamp debug-IDs and upload source maps (gap #1 of the source-map gap analysis). Design + measured limits: `docs/design/source-maps.md` §7.3; user docs: `packages/nextjs/README.md`. **webpack** (`--webpack`, default <= 15): one per-compilation plugin (client, server, edge) stamping inside the compilation (`PROCESS_ASSETS_STAGE_DEV_TOOLING + 1`, SRI-safe) and uploading exactly the files that compilation emitted (`files` mode, nothing walks `.next`). The generic `@bugsee/webpack-plugin` was NOT reused for Next: measured against a real build it cannot stamp the server compilation (assets named `../app/page.js`, output path `.next/server/chunks`) and its directory-wide upload of `.next` collides across the three compilations. **Turbopack** (default 16; `--turbopack` 15.x): `compiler.runAfterProductionCompile` (15.4.0+) runs the real `inject` + upload over `.next/static` and `.next/server`, bundles paired with maps by the `sourceMappingURL` pointer (Turbopack does not name a map after its bundle; Next 15.5 shares one map between two runtime chunks, which are left unstamped with a notice). Measured limits: Turbopack writes the SRI hashes BEFORE the hook, so an `experimental.sri` Turbopack build is left unmodified with a notice (webpack handles SRI); Next 16 errors on a `webpack` function without a `turbopack` config, so none is added on Turbopack builds; `compiler.define` (not `defineServer`) bakes the app identity. Policy: browser maps deleted after a confirmed upload, server/edge maps kept (`deleteServerMaps`). Composes with a user's `webpack`, `compiler.runAfterProductionCompile`, `compiler.define`, `productionBrowserSourceMaps`, function/async configs; inert for dev/start/export. Core change: `@bugsee/bundler-plugin-core` now also exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv`, `mergeBuildPluginEnv`. Found by the independent reviews and fixed: stamped webpack assets are written as STRING sources (a Buffer is opaque to webpack's RealContentHashPlugin, which renames `[contenthash]` chunks after the stamp, so every lazy chunk 404'd; the e2e now opens each build in headless Chromium and asserts the lazy chunk runs), the baked define is the RAW value (Next JSON-encodes `compiler.define` itself; a JSON string arrived double-quoted), own-files-only deletion on Turbopack, contained post-build hook, version floors (hook 15.4.0, define 15.1.0), idempotent application. Real builds (`@bugsee/nextjs-e2e`, `test/source-maps.e2e.ts`, `next` 15.5.28 and 16.4.6 x webpack/Turbopack + SRI cases, real `bugsee-cli`, mock collector, `next start` smoke): see the PR for the run.
Loading
Loading