From 3c15f07cda732fa6b407d33ffa26b0c24755ada9 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Fri, 6 Nov 2026 16:50:10 +0500 Subject: [PATCH 1/2] chore: drop Deno support and remove @bugsee/deno Deno is no longer a supported runtime. Removes the @bugsee/deno package, the umbrella deno entry/exports condition, the e2e Deno target, the CI Deno setup, the isDeno util, the Deno-only tracker code (Deno.systemMemoryInfo reader, Deno.Command vm_stat spawn), sample overrides and pending-changeset entries. The protocol RuntimeType 'deno' value is kept (backend wire contract). Co-Authored-By: Claude Sonnet 5.5 --- .changeset/delete-legacy-node-samplers.md | 1 - .changeset/gc-event-and-elu-percent.md | 1 - .changeset/memory-limit-gate.md | 1 - .changeset/node-disk-space.md | 1 - .changeset/node-process-tracker.md | 3 +- .changeset/node-runtime-traces.md | 3 +- .changeset/node-storage-tracker.md | 1 - .../omit-unmeasurable-event-loop-lag.md | 27 - .changeset/ram-system-free-macos-vmstat.md | 1 - .changeset/ram-system-free-semantics.md | 1 - .changeset/spec-zero-vs-omit.md | 1 - .github/workflows/ci.yml | 12 +- CLAUDE.md | 12 +- README.md | 2 +- dev-packages/packaging-guard/package.json | 1 - .../src/adapter-export-parity.test.ts | 5 +- docs/PROGRESS.md | 4 + docs/dev-environment.md | 9 +- docs/implementation-standards.md | 8 +- packages/bugsee/README.md | 5 +- packages/bugsee/package.json | 29 - packages/bugsee/src/deno.ts | 20 - packages/bugsee/src/export-parity.test-d.ts | 13 - packages/bugsee/src/export-parity.test.ts | 6 +- packages/bugsee/src/index.deno.ts | 41 -- packages/bugsee/src/lifecycle-exports.test.ts | 3 - packages/bugsee/src/node.ts | 4 +- packages/bugsee/src/public-surface.test-d.ts | 17 +- packages/bugsee/src/relaunch-options.test.ts | 7 +- packages/bugsee/src/server-entries.test.ts | 12 +- packages/bugsee/src/server-launch.ts | 12 +- packages/bugsee/src/wire.ts | 2 +- packages/bugsee/tsup.config.ts | 1 - packages/bun/src/launch.ts | 5 +- packages/capture/README.md | 2 +- packages/capture/src/absolutize-url.test.ts | 6 +- packages/capture/src/absolutize-url.ts | 2 +- .../capture/src/capture-state-producer.ts | 2 +- packages/capture/src/network-provider.test.ts | 2 +- packages/core/README.md | 4 +- packages/core/src/client.ts | 2 +- packages/core/src/relaunch-timer.test.ts | 2 +- packages/core/src/stack.ts | 2 +- packages/deno/LICENSE | 21 - packages/deno/README.md | 55 -- packages/deno/package.json | 58 -- .../deno/src/deno-serve-interceptor.test.ts | 180 ------- packages/deno/src/deno-serve-interceptor.ts | 85 --- packages/deno/src/environment.test.ts | 55 -- packages/deno/src/environment.ts | 30 -- packages/deno/src/index.exports.test.ts | 19 - packages/deno/src/index.ts | 16 - packages/deno/src/launch.test.ts | 501 ------------------ packages/deno/src/launch.ts | 77 --- .../deno/src/local-variables-gate.test.ts | 36 -- packages/deno/src/relaunch.test.ts | 45 -- packages/deno/src/relaunch.ts | 9 - packages/deno/tsconfig.json | 9 - packages/deno/tsup.config.ts | 4 - packages/deno/vitest.config.ts | 27 - packages/e2e-kit/src/collector.ts | 2 +- packages/elysia/README.md | 2 +- packages/elysia/src/index.ts | 2 +- packages/express/README.md | 2 +- packages/fastify/README.md | 2 +- packages/hapi/README.md | 2 +- packages/hapi/src/index.ts | 2 +- packages/hono/README.md | 2 +- packages/hono/src/index.ts | 2 +- packages/hono/src/middleware.ts | 2 +- packages/instrumentation-tests/README.md | 13 +- .../app/browser-scenario.ts | 2 +- .../instrumentation-tests/app/entry-deno.ts | 5 - .../app/entry-umbrella.ts | 5 +- .../instrumentation-tests/app/scenario.ts | 19 +- packages/instrumentation-tests/package.json | 3 +- .../test/durable-object-tenants.e2e.ts | 2 +- .../instrumentation-tests/test/edge.e2e.ts | 2 +- .../test/instrumentation.e2e.ts | 14 +- .../test/local-variables.e2e.ts | 2 +- .../test/opentelemetry.e2e.ts | 2 +- .../instrumentation-tests/test/runtimes.ts | 17 +- .../test/tsup-node-protocol.e2e.ts | 9 +- .../test/umbrella-conditions.e2e.ts | 7 +- .../test/umbrella.e2e.ts | 15 +- .../instrumentation-tests/vitest.config.ts | 2 +- packages/integration-shims/src/index.test.ts | 10 +- packages/integration-shims/src/index.ts | 2 +- packages/koa/README.md | 2 +- packages/koa/src/index.ts | 2 +- packages/node-utils/README.md | 6 +- .../src/batched-fs-chunk-storage.test.ts | 2 +- packages/node-utils/src/bundle-store.ts | 2 +- .../node-utils/src/capture-ring-drainer.ts | 2 +- .../node-utils/src/capture-ring-writer.ts | 2 +- packages/node-utils/src/fs-chunk-storage.ts | 2 +- packages/node-utils/src/worker-ring-worker.ts | 2 +- packages/node/README.md | 2 +- packages/node/src/data-location.ts | 2 +- packages/node/src/event-loop-watchdog.ts | 2 +- packages/node/src/fetch-server-wrap.test.ts | 2 +- packages/node/src/fetch-server-wrap.ts | 7 +- packages/node/src/http-server-interceptor.ts | 2 +- packages/node/src/launch.test.ts | 4 +- packages/node/src/launch.ts | 22 +- packages/node/src/local-variables.test.ts | 2 +- packages/node/src/local-variables.ts | 4 +- packages/node/src/server-instrument.test.ts | 2 +- packages/node/src/server-instrument.ts | 4 +- packages/node/src/system-events.test.ts | 2 +- packages/node/src/system-events.ts | 2 +- packages/node/src/trace-producers.ts | 4 +- packages/protocol/src/upload-contract.test.ts | 2 +- packages/protocol/src/wire.ts | 2 +- packages/trackers/README.md | 2 +- packages/trackers/package.json | 2 +- packages/trackers/src/node/gc-observer.ts | 4 +- .../src/node/guarded-event-loop.test.ts | 2 +- .../trackers/src/node/guarded-event-loop.ts | 10 +- packages/trackers/src/node/index.test.ts | 1 - packages/trackers/src/node/index.ts | 5 +- .../trackers/src/node/process-tracker.test.ts | 108 +--- packages/trackers/src/node/process-tracker.ts | 74 +-- .../trackers/src/node/runtime-readers.test.ts | 19 - packages/trackers/src/node/runtime-readers.ts | 30 +- packages/trackers/src/node/storage-tracker.ts | 2 +- packages/trackers/src/node/vm-stat.test.ts | 161 +----- packages/trackers/src/node/vm-stat.ts | 73 +-- packages/util/src/env.test.ts | 13 - packages/util/src/env.ts | 6 +- packages/util/src/index.test.ts | 1 - packages/util/src/index.ts | 1 - pnpm-lock.yaml | 88 +-- samples/angular-spa/pnpm-workspace.yaml | 1 - samples/browser-vanilla/pnpm-workspace.yaml | 1 - samples/express-api/pnpm-workspace.yaml | 1 - samples/fastify-api/pnpm-workspace.yaml | 1 - samples/node-service/pnpm-workspace.yaml | 1 - samples/node-service/scenarios.md | 2 +- samples/react-spa/pnpm-workspace.yaml | 1 - samples/solid-spa/pnpm-workspace.yaml | 1 - samples/svelte-spa/pnpm-workspace.yaml | 1 - samples/vue-spa/pnpm-workspace.yaml | 2 - .../webpack-sourcemaps/pnpm-workspace.yaml | 1 - scripts/ci-local.sh | 6 +- scripts/test-matrix.sh | 4 +- 146 files changed, 237 insertions(+), 2150 deletions(-) delete mode 100644 .changeset/omit-unmeasurable-event-loop-lag.md delete mode 100644 packages/bugsee/src/deno.ts delete mode 100644 packages/bugsee/src/index.deno.ts delete mode 100644 packages/deno/LICENSE delete mode 100644 packages/deno/README.md delete mode 100644 packages/deno/package.json delete mode 100644 packages/deno/src/deno-serve-interceptor.test.ts delete mode 100644 packages/deno/src/deno-serve-interceptor.ts delete mode 100644 packages/deno/src/environment.test.ts delete mode 100644 packages/deno/src/environment.ts delete mode 100644 packages/deno/src/index.exports.test.ts delete mode 100644 packages/deno/src/index.ts delete mode 100644 packages/deno/src/launch.test.ts delete mode 100644 packages/deno/src/launch.ts delete mode 100644 packages/deno/src/local-variables-gate.test.ts delete mode 100644 packages/deno/src/relaunch.test.ts delete mode 100644 packages/deno/src/relaunch.ts delete mode 100644 packages/deno/tsconfig.json delete mode 100644 packages/deno/tsup.config.ts delete mode 100644 packages/deno/vitest.config.ts delete mode 100644 packages/instrumentation-tests/app/entry-deno.ts diff --git a/.changeset/delete-legacy-node-samplers.md b/.changeset/delete-legacy-node-samplers.md index 6946d0f0c..41e4c7e45 100644 --- a/.changeset/delete-legacy-node-samplers.md +++ b/.changeset/delete-legacy-node-samplers.md @@ -1,7 +1,6 @@ --- '@bugsee/node': minor '@bugsee/bun': minor -'@bugsee/deno': minor --- Removed the legacy `createNodeSystemMetricsSampler` and `createGuardedSystemMetricsSampler` (and their `NodeSystemMetricsDeps` / `GuardedSystemMetricsDeps` types). Nothing in the SDK used them; node, Bun and Deno already build their system traces from `createNodeSystemTraceProducers`. A caller-supplied `systemMetricsSampler` option still works, and `PerfHooks` is still exported. diff --git a/.changeset/gc-event-and-elu-percent.md b/.changeset/gc-event-and-elu-percent.md index e82c6bcfb..33da2b9c8 100644 --- a/.changeset/gc-event-and-elu-percent.md +++ b/.changeset/gc-event-and-elu-percent.md @@ -1,7 +1,6 @@ --- '@bugsee/node': minor '@bugsee/bun': minor -'@bugsee/deno': minor '@bugsee/electron': minor '@bugsee/trackers': minor --- diff --git a/.changeset/memory-limit-gate.md b/.changeset/memory-limit-gate.md index bd0522723..ee29f2116 100644 --- a/.changeset/memory-limit-gate.md +++ b/.changeset/memory-limit-gate.md @@ -2,7 +2,6 @@ '@bugsee/trackers': minor '@bugsee/node': minor '@bugsee/bun': minor -'@bugsee/deno': minor --- `process_memory_limit` now has an explicit runtime gate, `measuresConstrainedMemory` (default on). Bun and Deno enable it only on Linux, the one platform where a cgroup cap exists, so the trace is omitted elsewhere instead of relying on the value filter alone. diff --git a/.changeset/node-disk-space.md b/.changeset/node-disk-space.md index a9fb3cf7b..c3f322e5b 100644 --- a/.changeset/node-disk-space.md +++ b/.changeset/node-disk-space.md @@ -1,7 +1,6 @@ --- '@bugsee/node': minor '@bugsee/bun': minor -'@bugsee/deno': minor --- New opt-in `captureDiskSpace` option: reports `disk_mem_free` and `disk_mem_total` (integer binary MB, Android parity) in `traces.system` for the filesystem the SDK's data directory lives on, polled every 5 s off the event loop (not held, so a failing statfs leaves a gap rather than a stale value). It is omitted when there is no data directory (in-memory or degraded launch) rather than falling back to `/` or the working directory, and when a reading is not sane rather than reported as 0. Default off. diff --git a/.changeset/node-process-tracker.md b/.changeset/node-process-tracker.md index 5539511b4..c0194546a 100644 --- a/.changeset/node-process-tracker.md +++ b/.changeset/node-process-tracker.md @@ -1,8 +1,7 @@ --- '@bugsee/node': minor '@bugsee/bun': minor -'@bugsee/deno': minor '@bugsee/trackers': minor --- -Node, Bun and Deno system traces now come from a per-process `ProcessTracker` in the new `@bugsee/trackers/node` entry, which replaces `@bugsee/node`'s `ProcessStatsTracker`. Trace names are unchanged, the GC observer and event-loop histogram now run only while their traces are enabled, and the runtime gates for Bun and Deno still omit the traces those runtimes cannot measure honestly. The `cpu_usage_*` traces no longer record a start value (it was a microsecond-window noise reading); they begin with the first sample. `@bugsee/node` (and so `@bugsee/bun` and `@bugsee/deno`, which re-export it) no longer exports `ProcessStatsTracker` and `ProcessStats`; it exports `processTrackerFor`, `resetProcessTracker` and the `ProcessTracker` type instead. +Node and Bun system traces now come from a per-process `ProcessTracker` in the new `@bugsee/trackers/node` entry, which replaces `@bugsee/node`'s `ProcessStatsTracker`. Trace names are unchanged, the GC observer and event-loop histogram now run only while their traces are enabled, and the runtime gates for Bun and Deno still omit the traces those runtimes cannot measure honestly. The `cpu_usage_*` traces no longer record a start value (it was a microsecond-window noise reading); they begin with the first sample. `@bugsee/node` (and so `@bugsee/bun` and `@bugsee/deno`, which re-export it) no longer exports `ProcessStatsTracker` and `ProcessStats`; it exports `processTrackerFor`, `resetProcessTracker` and the `ProcessTracker` type instead. diff --git a/.changeset/node-runtime-traces.md b/.changeset/node-runtime-traces.md index 5012bb9d3..2859dcaab 100644 --- a/.changeset/node-runtime-traces.md +++ b/.changeset/node-runtime-traces.md @@ -1,10 +1,9 @@ --- '@bugsee/node': minor '@bugsee/bun': minor -'@bugsee/deno': minor --- -Node, Bun and Deno now report more runtime traces in `traces.system`: +Node and Bun now report more runtime traces in `traces.system`: - `v8_heap_size_limit`, `v8_heap_available`, `v8_heap_malloced`, `v8_heap_peak_malloced` and the ceiling-based `ram_js_heap_total` / `_used` / `_free` (`total` is the heap limit, not the committed heap). Node and Deno only; omitted on Bun, whose heap statistics are not a V8 ceiling. - `process_memory_limit` (the cgroup cap), reported only for a real cap: omitted when `process.constrainedMemory()` is 0, the 2^64 sentinel, or at least total RAM. diff --git a/.changeset/node-storage-tracker.md b/.changeset/node-storage-tracker.md index da1e00765..58af85f74 100644 --- a/.changeset/node-storage-tracker.md +++ b/.changeset/node-storage-tracker.md @@ -1,7 +1,6 @@ --- '@bugsee/node': minor '@bugsee/bun': minor -'@bugsee/deno': minor '@bugsee/trackers': minor --- diff --git a/.changeset/omit-unmeasurable-event-loop-lag.md b/.changeset/omit-unmeasurable-event-loop-lag.md deleted file mode 100644 index d4fd29935..000000000 --- a/.changeset/omit-unmeasurable-event-loop-lag.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -'@bugsee/node': minor -'@bugsee/deno': minor ---- - -Event-loop lag traces are now omitted on Deno, instead of reporting a healthy loop through a freeze. - -`monitorEventLoopDelay()` exists on Deno, answers, and never throws — it simply never registers a -blocked loop. Measured with the histogram sampling an idle loop first, then a real 150 ms synchronous -block: - -``` -node idle floor 11.067ms -> 160.956ms (sees it) -bun idle floor 1.016ms -> 146.634ms (sees it) -deno idle floor 0.022ms -> 0.065ms (blind) -``` - -Reporting 0.065 ms of lag through a 150 ms freeze is the same class of wrong answer as a fabricated 0% -utilization: ~0 ms of lag is exactly what a healthy process reports. Unlike ELU there is no passive tell -— a zero `idle` gives ELU away, whereas Deno's histogram returns plausible small numbers — so the -composition root that knows the runtime declares it: `@bugsee/deno` passes `measuresEventLoopDelay: -false` and `event_loop_lag_ms`, `event_loop_lag_max_ms` and `event_loop_lag_p99_ms` are absent there. - -Node and Bun are unaffected; both measure correctly. The same reader also now omits rather than zeroes -when `monitorEventLoopDelay` throws outright (partial `perf_hooks`). Every other system metric is -unchanged on all runtimes, and ANR detection never used this mechanism — it polls a SharedArrayBuffer -heartbeat from a worker thread. diff --git a/.changeset/ram-system-free-macos-vmstat.md b/.changeset/ram-system-free-macos-vmstat.md index f4e0000b8..a282028f9 100644 --- a/.changeset/ram-system-free-macos-vmstat.md +++ b/.changeset/ram-system-free-macos-vmstat.md @@ -2,7 +2,6 @@ '@bugsee/trackers': minor '@bugsee/node': minor '@bugsee/bun': minor -'@bugsee/deno': minor --- `ram_system_free` is now reported on macOS for Node and Bun and Deno. It reads `/usr/bin/vm_stat` asynchronously at most once per 10 seconds, and only while the system-memory stage has a listener. The value is (Pages free + File-backed pages + Pages purgeable) times the page size, the same definition as Electron's `getSystemMemoryInfo` on macOS, so Electron, Node and Bun agree. The spawn uses the absolute path with no shell or arguments, a 2 s timeout and a small output cap. It never overlaps, serves a value for at most two intervals before omitting, and any failure omits the trace and is reported once per failure streak through `onError`. The child is killed when the stage loses its last listener, and an empty read caused by a resumed `execFile` timeout is a silent miss. On Deno the spawn goes through `Deno.Command` (works with only `--allow-run=/usr/bin/vm_stat`, never prompts) and happens only when `Deno.permissions.querySync` already reports it granted; otherwise Deno answers `Deno.systemMemoryInfo().available`, a larger estimate (free + inactive pages) than the vm_stat definition. `current()` on an unarmed stage reads the cache only and never spawns. `@bugsee/trackers/node` gains `createVmStatSampler` and `parseVmStat`, and `ProcessEnv` gains `readsVmStat` (default `true`; `false` opts out), `vmStat` and `vmStatExecFile`, and `@bugsee/trackers/node` also exports `createDenoExecFile` and `denoVmStatGranted`. To opt out, pass `systemTraceProducers: createNodeSystemTraceProducers({ readsVmStat: false })` to `launch`. diff --git a/.changeset/ram-system-free-semantics.md b/.changeset/ram-system-free-semantics.md index b76f5d0bb..07e1303c3 100644 --- a/.changeset/ram-system-free-semantics.md +++ b/.changeset/ram-system-free-semantics.md @@ -1,7 +1,6 @@ --- '@bugsee/node': minor '@bugsee/bun': minor -'@bugsee/deno': minor '@bugsee/electron': minor '@bugsee/trackers': minor --- diff --git a/.changeset/spec-zero-vs-omit.md b/.changeset/spec-zero-vs-omit.md index 71ed4b229..577206459 100644 --- a/.changeset/spec-zero-vs-omit.md +++ b/.changeset/spec-zero-vs-omit.md @@ -2,7 +2,6 @@ '@bugsee/trackers': minor '@bugsee/node': minor '@bugsee/bun': minor -'@bugsee/deno': minor '@bugsee/electron': minor --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8cf5a7852..cdb952f24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,7 +95,7 @@ jobs: # RUN here. With this set, a too-old Node fails that suite instead of skipping it silently. BUGSEE_REQUIRE_OTEL3: '1' - # End-to-end harnesses: the REAL SDK booted in real node/bun/deno processes against a + # End-to-end harnesses: the REAL SDK booted in real node/bun processes against a # mock collector, plus the real-framework suites (nuxt / sveltekit / astro / next). # # These existed but were OUTSIDE the gate until 2026-07-27: the `check` job runs @@ -104,13 +104,13 @@ jobs: # identified that as the root cause of most of its ~90 severe findings surviving ~100% unit coverage. # # Separate job so it runs alongside `check` and so its extra runtime setup - # (bun, deno) is isolated. Bun and Deno are installed deliberately: the harness SKIPS + # (bun) is isolated. Bun is installed deliberately: the harness SKIPS # a runtime whose binary is absent (packages/instrumentation-tests/test/runtimes.ts), # so without them CI would go green while testing strictly less. # # Hosted runners are provisioned per job, so the two jobs run in parallel. e2e: - name: E2E (node · bun · deno · real frameworks) + name: E2E (node · bun · real frameworks) runs-on: ubuntu-latest timeout-minutes: 45 steps: @@ -128,11 +128,6 @@ jobs: - name: Setup Bun uses: oven-sh/setup-bun@v2 - - name: Setup Deno - uses: denoland/setup-deno@v2 - with: - deno-version: v2.x - - name: Install dependencies run: pnpm install --frozen-lockfile @@ -151,7 +146,6 @@ jobs: run: | node --version bun --version - deno --version # Playwright ships a downloader, not the browsers: `pnpm install` does not fetch them, so # `browser.e2e.ts` fails with "Executable doesn't exist at .../chrome-headless-shell". diff --git a/CLAUDE.md b/CLAUDE.md index 7c3fa3568..6e6878470 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,7 +10,7 @@ Design implication: runtime-portable code is the default. Anything runtime-speci ## Current state -Runnable SDKs exist for **Node, Browser, Bun, Deno, Electron, Cloudflare/Vercel edge, and Web/Service Workers**, plus frontend/meta-framework/backend adapters. Implementation is tracked in **`docs/PROGRESS.md`** (the hand-off doc — read it first); architecture spec is `docs/design/sdk-design.md` (Draft v3); toolchain + commands are `docs/dev-environment.md`. The repo is on **GitHub** (`github.com/bugsee/bugsee-javascript`, default branch `main`) with a **GitHub Actions CI gate** (`.github/workflows/ci.yml`: lint → typecheck → cycles → per-package coverage → e2e). **Work directly on `main`** — the SDK is unpublished and in active development, so feature branches and PRs are unnecessary overhead; commit and push to `main`. The gates still apply in full before every commit (see §Implementation standards). +Runnable SDKs exist for **Node, Browser, Bun, Electron, Cloudflare/Vercel edge, and Web/Service Workers**, plus frontend/meta-framework/backend adapters. Implementation is tracked in **`docs/PROGRESS.md`** (the hand-off doc — read it first); architecture spec is `docs/design/sdk-design.md` (Draft v3); toolchain + commands are `docs/dev-environment.md`. The repo is on **GitHub** (`github.com/bugsee/bugsee-javascript`, default branch `main`) with a **GitHub Actions CI gate** (`.github/workflows/ci.yml`: lint → typecheck → cycles → per-package coverage → e2e). **Work directly on `main`** — the SDK is unpublished and in active development, so feature branches and PRs are unnecessary overhead; commit and push to `main`. The gates still apply in full before every commit (see §Implementation standards). **Implemented (test-first, reviewed, on `main`):** - Tier-0: `@bugsee/types`, `@bugsee/util`, `@bugsee/logger`, `@bugsee/protocol`, `@bugsee/service`. @@ -19,11 +19,11 @@ Runnable SDKs exist for **Node, Browser, Bun, Deno, Electron, Cloudflare/Vercel - Shared capture: `@bugsee/capture` (console→log; fetch/xhr/ws/sse/webtransport → network umbrella; system traces/events providers). - Node platform: `@bugsee/node-utils` (httpRequest transport, fs storage + bundle store) and `@bugsee/node` (`launch()`, node:http interceptor, env builder, detection providers, system metrics). Plus opt-in **node diagnostics**: rolling V8 CPU profiling (`profile.json`) + ANR/event-loop-hang detection (worker-thread watchdog → `AppHang` reports). Plus **multi-instance on-disk coexistence** (`docs/design/multi-instance-disk-coexistence.md`): several aggregators (worker_threads / processes) safely share one `dataDir` — each writes a per-instance subtree `/--/` (+ `owner.json` + `.live` heartbeat); on launch a coordinator opportunistically recovers DEAD sibling subtrees (Android-canonical), gated by a portable liveness check (`process.kill(pid,0)` + heartbeat staleness — the native-free replacement for Java's `FileLock`). - Browser platform: `@bugsee/browser-utils` (fetch transport, IndexedDB storage + bundle store) and `@bugsee/browser` (`launch()`, global error/network capture, IndexedDB-persisted capture). -- Bun + Deno platforms: `@bugsee/bun` / `@bugsee/deno` — re-export the `@bugsee/node` composition and override only the runtime identity probe (+ a shared guarded `perf_hooks` sampler); **full Node feature parity incl. profiling + ANR**. CPU profiling via `node:inspector` is REAL on Deno — measured 2026-09-01 on Deno 2.9.5: `Profiler.start/stop` returned 11 nodes / 241 samples with real `timeDeltas`. (A research pass claimed it was a stub; that was wrong, and a `CLAUDE.md` edit made on it has been reverted. `docs/PROGRESS.md` was right.) **THREE REAL cross-runtime divergences, all measured, all now FIXED (the third is the worst — see the end of this bullet). The first:** `performance.eventLoopUtilization()` returns flat `{idle:0, active:0}` on BOTH Bun and Deno while Node reports real values, and `guardedElu` only caught throws — so the SDK shipped a plausible 0% utilization trace for ever. It now OMITS the trace when the runtime cannot answer, discriminating on `idle` (which accumulates wall-clock time on any honest implementation, so it cannot be zero at a 1s cadence) rather than on `utilization`, so a genuinely idle process still reports a truthful 0. Verified on real runtimes: present on node, absent on bun and deno. And **`monitorEventLoopDelay` never sees a synchronous block on Deno** — measured with the histogram actually sampling before the block (an earlier probe of mine blocked immediately after `enable()` and so only ever read the idle floor, which is how this line was twice written wrong): a real 150 ms block reads max **151.3 ms (node) / 144.0 ms (bun) / 0.421 ms (deno)**. Bun is fine; only its IDLE FLOOR differs (11.3 / 1.05 / 0.024 ms), which is a timer-granularity artifact, not blindness. So the `event_loop_lag` system trace (`trackers/guarded-event-loop.ts`, `trace-producers.ts`) is non-functional on Deno in the same way ELU is — it reports a healthy loop through a real stall. **NOW FIXED the same way as ELU, but by a runtime GATE rather than a passive tell — Deno's histogram answers and never throws, so nothing lower down can detect it: `@bugsee/deno` passes `measuresEventLoopDelay: false` and the three `event_loop_lag_*` traces are OMITTED there rather than reporting a healthy loop through a freeze.** **ANR detection is NOT affected**: it uses a SharedArrayBuffer heartbeat polled by a worker thread (`event-loop-watchdog.ts:5-6`), not `perf_hooks` — though ANR has not itself been measured on Deno. **THIRD (2026-09-02, the dangerous one): LOCAL-VARIABLE CAPTURE FREEZES DENO.** With `captureLocalVariables: {includeCaught: true}` a real-SDK repro on Deno 2.9.6 produced NO output and never exited — the freeze lands during launch, before any application code, because the SDK's own guarded startup paths throw-and-catch internally and every caught throw is a pause. `Debugger.enable` and `setPauseOnExceptions` both answer "ok"; the pause then arrives and `Debugger.paused` never reaches an in-process listener, so nothing resumes. On the default `uncaught` path Deno never pauses at all, so the feature could only ever attach a debugger and return nothing. Bun 1.4.0 is safe but inert — `Debugger.enable` is REFUSED ("requires an active inspector"). **Both are now hard-gated in `@bugsee/{deno,bun}/src/launch.ts` with `captureLocalVariables: false` placed AFTER `...options`, so a caller cannot switch the freeze back on** — as a default it would spread before the caller's options and be overridden. Same lesson as ELU: on Deno, "the call succeeded" is not evidence the thing happened. +- Bun platform: `@bugsee/bun` — re-exports the `@bugsee/node` composition and overrides only the runtime identity probe (+ a shared guarded `perf_hooks` sampler); **full Node feature parity incl. profiling + ANR**. Bun-specific gates (measured): `performance.eventLoopUtilization()` answers flat zeros, so the ELU trace is OMITTED rather than reported as 0% (discriminated on `idle`, which accumulates on any honest implementation); `captureLocalVariables` is hard-gated OFF in `@bugsee/bun/src/launch.ts` AFTER `...options` (`Debugger.enable` is refused without an active inspector, so the feature would be silently inert). **Deno support was DROPPED (2026-11-06, owner decision)** — `@bugsee/deno`, its umbrella `deno` entry/condition, e2e target, CI job and the Deno-only tracker code (`createDenoMemoryReader`, `Deno.Command` vm_stat spawn, `isDeno`) are removed; the protocol's `'deno'` runtime-type enum value is KEPT (backend wire contract). Generic seams introduced for it (`measuresEventLoopDelay`, `measuresGc`, …) remain as launch options. Historical Deno analysis lives only in `docs/review/` and `docs/research/`. - 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/deno processes against a mock collector and asserts the uploaded bundle (`pnpm test:e2e`; not in `pnpm test`). -- 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`/`Deno.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). +- 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`). +- 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). **No unbuilt packages remain:** `@bugsee/replay-canvas` (the opt-in canvas-replay add-on) is now built (RPC1–RPC6, `docs/design/replay-canvas.md`). `vite-plugin`/`webpack-plugin` are intentionally **thin re-export wrappers** over the built `@bugsee/bundler-plugin-core` (the #158 source-map / debug-id tooling — DONE), not stubs. Everything once listed here is now built + reviewed: `webworker`, `replay` (RP0–RP6), all frontend adapters (`react`/`vue`/`svelte`/`solid`/`angular`/preact-compat), the meta-framework adapters (`nextjs`/`nuxt`/`remix`/`sveltekit`/`astro`), the backend adapters (`express`/`fastify`/`nestjs`/`hono`/`elysia`/`hapi`/`koa`), `electron`, edge (`cloudflare`/`vercel-edge`), and `integration-shims`. @@ -41,7 +41,7 @@ Runnable SDKs exist for **Node, Browser, Bun, Deno, Electron, Cloudflare/Vercel - **`*.user` streams belong to the APPLICATION, not the SDK** (product owner, verbatim): *"'events.user' is totally the wrong target for it. SDK code MUST NOT write anything into 'user.\*' streams. These are for user supplied data."* `events.user`/`traces.user` carry ONLY `client.event()`/`client.trace()` output. SDK-captured device input has its own stream — **`input` → `input.json`** (`createInputProvider`, mobile-canonical, viewer `RecordingTouchEvent` shape). Need a new SDK-captured stream? Register a FileType (`packages/protocol/src/constants.ts` + `upload-contract.schema.json`; a drift test enforces the pair). Design §8.4.1. - **One place per system wire name, enforced against the spec.** Every `traces.system` / `events.system` name is a constant in `@bugsee/protocol` `system-names.ts` (`TraceName` / `EventName`, + `TRACE_SPEC`/`EVENT_PARAMS` metadata); producers reference it and never spell a name as a literal (`TraceProducerBase.emit` takes a `TraceName`). `@bugsee/instrumentation-tests` `test/spec-drift.test.ts` compares the registry with the vendored snapshot of the JS platform spec (`packages/protocol/spec/*.snapshot.json`, refresh with `pnpm spec:refresh`) and fails on drift, on a literal in producer code, and on an emit style that contradicts the spec's held column. A new name = spec first, then `pnpm spec:refresh`, then register it. See `docs/PROGRESS.md` (2026-10-27). - **One definition of "sensitive field"**: `SENSITIVE_INPUT_MATCHERS`/`isSensitiveInput` in `@bugsee/core`. Replay masking, WebView obscuring and input capture all derive from it — shape it, never restate it (three copies once drifted apart and a card field went unmasked). -- **Runtime-portable by default.** Anything runtime-specific (DOM, `process`, `window`, `fs`, Electron, Bun/Deno APIs) lives behind a runtime adapter or conditional entry point — never imported unconditionally from shared code. +- **Runtime-portable by default.** Anything runtime-specific (DOM, `process`, `window`, `fs`, Electron, Bun APIs) lives behind a runtime adapter or conditional entry point — never imported unconditionally from shared code. ## Implementation standards (binding — full methodology in `docs/implementation-standards.md`) @@ -53,7 +53,7 @@ Mandatory for all code: 4. **Mutator loop:** inject a bug into the new/changed entity, run the test, confirm it **fails** (catches the bug); repeat with different mutations while any mutation survives undetected — **hard limit: 10 iterations**. If a mutation survives, strengthen the test before continuing. 5. **Roll back every injected mutation**, leaving the clean, valid implementation. Never commit a mutation. 3. **Integration tests.** Any class that interacts with other classes, or any cross-module/cross-package import/export boundary, gets integration tests following the same mutator discipline (#2). -4. **Coverage gate (CI, per-runtime):** **100% line, ≥90% branch.** Coverage runs per target runtime (browser/node/bun/deno/…). Unreachable or platform-guarded code may be excluded only via an explicit `/* v8 ignore … */` annotation **with a one-line justification**. +4. **Coverage gate (CI, per-runtime):** **100% line, ≥90% branch.** Coverage runs per target runtime (browser/node/bun/…). Unreachable or platform-guarded code may be excluded only via an explicit `/* v8 ignore … */` annotation **with a one-line justification**. 5. **Mutation testing (Stryker): opt-in**, not a blocking gate — run on demand/nightly to audit test strength. The per-entity mutator loop (#2) is the always-on primary discipline. 6. **Multi-agent code review (per feature) — convergent gate.** Once a feature's implementation and tests are complete and gates (#2/#4) pass, run a review with **multiple specialized agents in parallel** validating **both the implementation and the tests**. Agents are **read-only** and must **make no assumptions, not hallucinate, take no shortcuts, and re-check when unsure** — every finding cites a concrete `file:line`. Triage findings (record dismissals), fix real ones **test-first**, then start a **fresh** multi-agent review. Repeat until a full round yields **zero new real findings**. Full process in `docs/implementation-standards.md` §7. 7. **Tooling:** Vitest (unit + integration, `--typecheck` for type tests), Playwright (browser e2e), per-runtime smoke harnesses. See design §12.1/§13. diff --git a/README.md b/README.md index 52e224300..0c35db692 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Bugsee JavaScript SDK -A single SDK targeting every JavaScript runtime — browsers, Node.js, Bun, Deno, Electron, Cloudflare Workers, Vercel Edge, and Web/Service Workers. +A single SDK targeting every JavaScript runtime — browsers, Node.js, Bun, Electron, Cloudflare Workers, Vercel Edge, and Web/Service Workers. > **Status:** implemented. Runnable SDKs exist for every target runtime, plus frontend, meta-framework and > backend adapters, session replay, APM, OpenTelemetry and source-map tooling. Development follows test-first diff --git a/dev-packages/packaging-guard/package.json b/dev-packages/packaging-guard/package.json index 54b32efad..9e335cfec 100644 --- a/dev-packages/packaging-guard/package.json +++ b/dev-packages/packaging-guard/package.json @@ -20,7 +20,6 @@ "@bugsee/capture": "workspace:*", "@bugsee/cloudflare": "workspace:*", "@bugsee/core": "workspace:*", - "@bugsee/deno": "workspace:*", "@bugsee/electron": "workspace:*", "@bugsee/elysia": "workspace:*", "@bugsee/express": "workspace:*", diff --git a/dev-packages/packaging-guard/src/adapter-export-parity.test.ts b/dev-packages/packaging-guard/src/adapter-export-parity.test.ts index 2b9ff39f6..3850d51bf 100644 --- a/dev-packages/packaging-guard/src/adapter-export-parity.test.ts +++ b/dev-packages/packaging-guard/src/adapter-export-parity.test.ts @@ -9,7 +9,6 @@ import * as bun from '@bugsee/bun'; import { getDefaultNetworkSanitizer } from '@bugsee/capture'; import * as cloudflare from '@bugsee/cloudflare'; import { addReportAttachment, BugseeStatus, LifecycleEvents } from '@bugsee/core'; -import * as deno from '@bugsee/deno'; import * as electronMain from '@bugsee/electron/main'; import * as electronRenderer from '@bugsee/electron/renderer'; import * as nextClient from '@bugsee/nextjs/client'; @@ -61,7 +60,6 @@ const targets: Record< '@bugsee/browser': { entry: browser }, '@bugsee/node': { entry: node }, '@bugsee/bun': { entry: bun }, - '@bugsee/deno': { entry: deno }, '@bugsee/vercel-edge': { entry: vercelEdge }, '@bugsee/cloudflare': { entry: cloudflare }, '@bugsee/webworker': { entry: webworker }, @@ -146,11 +144,10 @@ describe('the re-exports are the SAME functions, not look-alikes', () => { }); it('the umbrella-based adapters keep relaunch off the plain-launch path where their launch differs', () => { - // Cloudflare / Bun / Deno / Next.js server run a launch that adds defaults on top of the shared one; the + // Cloudflare / Bun / Next.js server run a launch that adds defaults on top of the shared one; the // package-level `relaunch` must be THEIR relaunch, not the one re-exported from the layer below. expect(cloudflare.relaunch).not.toBe(vercelEdge.relaunch); expect(bun.relaunch).not.toBe(node.relaunch); - expect(deno.relaunch).not.toBe(node.relaunch); expect(nextServer.relaunch).not.toBe(umbrellaNode.relaunch); }); }); diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 481a2f9ce..79b7fb35e 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -1310,6 +1310,10 @@ recorded" was false. Still open from #120: WebKit/Firefox projects, the 22-secret smoke, `document.open`. #119 (other masking-option gaps on re-observed observers) is untouched. +### 2026-11-06 — Deno support dropped (owner decision) + +Removed `@bugsee/deno` and everything that existed only for it: the umbrella `deno` entry + `exports` condition + `./deno` subpath, the `deno` e2e target and `entry-deno.ts`, the `Deno.serve` branch of the native-server scenario, the CI `Setup Deno` step and `deno --version` check, the `isDeno` util, the Deno-only tracker code (`createDenoMemoryReader`, `createDenoExecFile`/`denoVmStatGranted`, the `Deno.Command` vm_stat spawn) with their tests, sample `pnpm-workspace` overrides, and the `@bugsee/deno` lines in pending changesets (plus the Deno-only `omit-unmeasurable-event-loop-lag` changeset). KEPT on purpose: the protocol `RuntimeType` `'deno'` value (backend wire contract; historical data) and the generic launch seams (`measuresEventLoopDelay`, `measuresGc`, …). `docs/review/`, `docs/research/` and the older design docs still describe Deno as it was; they are history, not as-built. Entries below that mention Deno are superseded by this one. + ### 2026-10-27 — Spec-conformance guard for the system traces and events (spec items C17 + C24) The JavaScript platform spec (`bugsee/specs` `sdk/reporting/platforms/javascript.md`) is now enforced by a test, and every diff --git a/docs/dev-environment.md b/docs/dev-environment.md index 0610f1634..7eb5bd617 100644 --- a/docs/dev-environment.md +++ b/docs/dev-environment.md @@ -11,7 +11,6 @@ | **Node.js** | **22.18+, 24.11+ or ≥26** (not 23, not 24.0-24.10) | Development tooling runtime (tsup 9 engine range: pnpm, Vitest, Rollup, tsup, lint, type-check, builds). The *SDK runtime* floor is unchanged: Node ≥18 (see Tier-1 below) | | **pnpm** | **≥9** | Package manager (strict node_modules, monorepo workspaces) | | Bun | ≥1.1.13 | Building/smoke-testing `@bugsee/bun`; optional otherwise | -| Deno | ≥1.36 | Smoke-testing `@bugsee/deno` (`--allow-net`, `--allow-write`) | | Wrangler (Cloudflare) | current | Smoke-testing `@bugsee/cloudflare` (`wrangler dev`) | | Vercel CLI | current | Smoke-testing `@bugsee/vercel-edge` | | Playwright browsers | current | Browser e2e (`npx playwright install`) | @@ -20,7 +19,7 @@ Node + pnpm are the only hard requirements for general development; the others a ## Target runtimes -Tooling runs on Node; the SDK is **built for and smoke-tested on** each target runtime separately (coverage is measured per runtime — see Testing). Tier-1: browsers, Node ≥18, Bun ≥1.1.13, Deno ≥1.36. Tier-2: Cloudflare Workers, Vercel Edge, Web/Service Workers. Electron ships in v1 (`@bugsee/electron`, main + renderer + native). Module format: **ESM-only** for tier-0; **ESM+CJS** for core/platform/framework/umbrella (design §12.5). +Tooling runs on Node; the SDK is **built for and smoke-tested on** each target runtime separately (coverage is measured per runtime — see Testing). Tier-1: browsers, Node ≥18, Bun ≥1.1.13. Tier-2: Cloudflare Workers, Vercel Edge, Web/Service Workers. Electron ships in v1 (`@bugsee/electron`, main + renderer + native). Module format: **ESM-only** for tier-0; **ESM+CJS** for core/platform/framework/umbrella (design §12.5). ## Package manager & monorepo @@ -60,7 +59,7 @@ Methodology (test-first TDD + per-entity **mutator loop** + integration tests at | **Vitest + v8 coverage** | Coverage gate **100% line / ≥90% branch, per runtime** (CI-blocking); exclusions only via annotated `/* v8 ignore */` + justification | | **Stryker Mutator** (Vitest runner) | Mutation testing — **opt-in** (on-demand/nightly), not a blocking gate | | **Playwright** | Browser e2e | -| Per-runtime smoke harnesses | `bun test` / `deno test` / `wrangler dev` / Vercel CLI, under `dev-packages/` | +| Per-runtime smoke harnesses | `bun test` / `wrangler dev` / Vercel CLI, under `dev-packages/` | | **Verdaccio** + ~10 fixture apps | Framework e2e | | Bundler tests (`dev-packages/bundler-tests/`) | Tree-shake regression across webpack/rollup/vite/esbuild/turbopack/parcel | | **size-limit** + **bundlemon** | Bundle-size budgets (CI-blocking); PR comments | @@ -90,7 +89,7 @@ Package manager: **pnpm 11.3.0** (declared in root `package.json` `packageManage ```bash pnpm ci:local # the `check` job: lint → typecheck → cycles → coverage → unit (~35 s) -pnpm ci:local --e2e # also the `e2e` job: node · bun · deno · real frameworks (~4 min) +pnpm ci:local --e2e # also the `e2e` job: node · bun · real frameworks (~4 min) pnpm ci:local --force # ignore the turbo cache so every package really re-runs ``` @@ -189,7 +188,7 @@ pnpm mutation # turbo run mutation (per-package Stry ### Per-runtime smoke + Node-version matrix -- **Cross-runtime e2e:** `pnpm test:e2e` (`@bugsee/instrumentation-tests`) boots the REAL SDK in separate node (via tsx) / bun / deno processes against a mock collector and asserts the uploaded bundles (logs/network/profile/ANR/crash/server-context/disk-recovery/off-thread-worker). A runtime whose binary is absent is skipped. +- **Cross-runtime e2e:** `pnpm test:e2e` (`@bugsee/instrumentation-tests`) boots the REAL SDK in separate node (via tsx) / bun processes against a mock collector and asserts the uploaded bundles (logs/network/profile/ANR/crash/server-context/disk-recovery/off-thread-worker). A runtime whose binary is absent is skipped. - **Cross-Node-version matrix:** `pnpm test:matrix` (`scripts/test-matrix.sh`, nvm-based, CI-agnostic) runs a vitest-free scenario smoke (`smoke.ts`) via `tsx` under each installed Node version — covering **Node 18**, where vitest 4 cannot load (`rolldown`'s `node:util.styleText`). `pnpm test:matrix 18 20` picks a subset; `--full` also runs `pnpm test` on each Node ≥ 20. (Complementary axes: `pnpm test` is the host-Node unit suite; `pnpm test:e2e` is the cross-runtime axis.) - The Node SDK's in-process e2e coverage is also in `packages/node/src/launch.integration.test.ts` (real loopback `http.createServer`, full session → issue → signed PUT → durable-queue recovery). diff --git a/docs/implementation-standards.md b/docs/implementation-standards.md index 45b8ad6b2..96cde5243 100644 --- a/docs/implementation-standards.md +++ b/docs/implementation-standards.md @@ -57,12 +57,12 @@ Integration tests follow the **same mutator discipline (§2)** — inject bugs a ## 4. Coverage gate (CI) -- **100% line, ≥90% branch**, enforced in CI and **measured per target runtime** (browser/node/bun/deno/workers/…), since platform branches only execute on their own runtime. Coverage is the union/per-package view appropriate to each package's runtime(s). +- **100% line, ≥90% branch**, enforced in CI and **measured per target runtime** (browser/node/bun/workers/…), since platform branches only execute on their own runtime. Coverage is the union/per-package view appropriate to each package's runtime(s). - Tooling: Vitest coverage (v8 provider). - **Exclusions are the only escape hatch and require justification.** Unreachable defensive branches or platform-guarded code may be excluded with an explicit annotation **and a one-line reason**: ```ts - /* v8 ignore next 3 -- platform guard: only reachable on Deno, covered in deno smoke suite */ - if (isDeno) { ... } + /* v8 ignore next 3 -- platform guard: only reachable on Bun, covered in bun smoke suite */ + if (isBun) { ... } ``` No blanket file-level ignores without review. Excluded lines are still expected to be covered by the relevant per-runtime smoke suite where possible. @@ -79,7 +79,7 @@ Integration tests follow the **same mutator discipline (§2)** — inject bugs a |---|---| | Unit + integration | Vitest (`--typecheck` for type-level contracts) | | Browser e2e | Playwright | -| Per-runtime smoke | `bun test` / `deno test` / `wrangler dev` / Vercel CLI harnesses (`dev-packages/`) | +| Per-runtime smoke | `bun test` / `wrangler dev` / Vercel CLI harnesses (`dev-packages/`) | | Coverage | Vitest + v8 provider (100% line / ≥90% branch, per runtime) | | Mutation (opt-in) | Stryker Mutator (Vitest runner) | | Wire-format | Vitest snapshots in `dev-packages/wire-snapshots/` (snapshot update requires a `backend-ref:` commit line — design §13) | diff --git a/packages/bugsee/README.md b/packages/bugsee/README.md index 8e184b36c..952999993 100644 --- a/packages/bugsee/README.md +++ b/packages/bugsee/README.md @@ -4,7 +4,7 @@ The Bugsee JavaScript SDK: one package that captures crashes, errors, logs, netw Part of the Bugsee JavaScript SDK (public beta, 0.1.0-beta.x). -This is the main entry point. Install it directly. It resolves to the right build for your runtime through package `exports` conditions (browser, Node.js, Bun, Deno, Cloudflare Workers, Vercel Edge, Web Workers), and it turns on performance monitoring (web vitals and transactions) by default. +This is the main entry point. Install it directly. It resolves to the right build for your runtime through package `exports` conditions (browser, Node.js, Bun, Cloudflare Workers, Vercel Edge, Web Workers), and it turns on performance monitoring (web vitals and transactions) by default. ## Install @@ -44,7 +44,6 @@ bugsee.logException(new Error('payment failed')); | --- | --- | --- | | Browser, Node.js | `@bugsee/bugsee` | `@bugsee/bugsee` | | Bun | `@bugsee/bun` | `@bugsee/bun` | -| Deno | `@bugsee/deno` (`deno add npm:@bugsee/deno`) | `@bugsee/deno` | | Electron | `@bugsee/electron` | `@bugsee/electron/main`, `/preload`, `/renderer` | | Cloudflare Workers | `@bugsee/cloudflare` | `@bugsee/cloudflare` | | Vercel Edge | `@bugsee/vercel-edge` | `@bugsee/vercel-edge` | @@ -54,7 +53,7 @@ bugsee.logException(new Error('payment failed')); | Next.js, Nuxt, Remix, SvelteKit, Astro | `@bugsee/nextjs`, `@bugsee/nuxt`, `@bugsee/remix`, `@bugsee/sveltekit`, `@bugsee/astro` | the adapter package | | Express, Fastify, NestJS, Hono, Koa, hapi, Elysia | `@bugsee/bugsee` and `@bugsee/express`, `@bugsee/fastify`, `@bugsee/nestjs`, `@bugsee/hono`, `@bugsee/koa`, `@bugsee/hapi`, `@bugsee/elysia` | `@bugsee/bugsee` | -The umbrella also ships explicit subpath entries (`@bugsee/bugsee/node`, `/bun`, `/deno`, `/workerd`, `/edge-light`, `/worker`) for tools that do not honor `exports` conditions. +The umbrella also ships explicit subpath entries (`@bugsee/bugsee/node`, `/bun`, `/workerd`, `/edge-light`, `/worker`) for tools that do not honor `exports` conditions. `@bugsee/browser` and `@bugsee/node` are the platform builds this package wraps. You do not need to install them. diff --git a/packages/bugsee/package.json b/packages/bugsee/package.json index 9c8bc11a9..1a78ddfb5 100644 --- a/packages/bugsee/package.json +++ b/packages/bugsee/package.json @@ -25,10 +25,6 @@ "types": "./src/index.bun.ts", "import": "./src/index.bun.ts" }, - "deno": { - "types": "./src/index.deno.ts", - "import": "./src/index.deno.ts" - }, "worker": { "types": "./src/index.worker.ts", "import": "./src/index.worker.ts" @@ -54,10 +50,6 @@ "types": "./src/index.bun.ts", "import": "./src/index.bun.ts" }, - "./deno": { - "types": "./src/index.deno.ts", - "import": "./src/index.deno.ts" - }, "./workerd": { "types": "./src/index.workerd.ts", "import": "./src/index.workerd.ts" @@ -117,16 +109,6 @@ "default": "./dist/index.bun.cjs" } }, - "deno": { - "import": { - "types": "./dist/index.deno.d.ts", - "default": "./dist/index.deno.js" - }, - "require": { - "types": "./dist/index.deno.d.cts", - "default": "./dist/index.deno.cjs" - } - }, "worker": { "import": { "types": "./dist/index.worker.d.ts", @@ -188,16 +170,6 @@ "default": "./dist/index.bun.cjs" } }, - "./deno": { - "import": { - "types": "./dist/index.deno.d.ts", - "default": "./dist/index.deno.js" - }, - "require": { - "types": "./dist/index.deno.d.cts", - "default": "./dist/index.deno.cjs" - } - }, "./workerd": { "import": { "types": "./dist/index.workerd.d.ts", @@ -237,7 +209,6 @@ "@bugsee/capture": "workspace:*", "@bugsee/cloudflare": "workspace:*", "@bugsee/core": "workspace:*", - "@bugsee/deno": "workspace:*", "@bugsee/node": "workspace:*", "@bugsee/opentelemetry": "workspace:*", "@bugsee/performance": "workspace:*", diff --git a/packages/bugsee/src/deno.ts b/packages/bugsee/src/deno.ts deleted file mode 100644 index b4e7e528e..000000000 --- a/packages/bugsee/src/deno.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { relaunchWith } from '@bugsee/core'; -import { launchCore } from '@bugsee/deno'; -import { type Bugsee, type BugseeServerLaunchOptions, createServerLaunch } from './server-launch'; - -// The `bugsee` umbrella launch() for DENO — selected via the package `exports` "deno" condition, which must -// be listed BEFORE "node" because Deno sets both under node compatibility. -// -// Without this entry the umbrella resolved to @bugsee/node on Deno, silently losing the `Deno.serve` -// interceptor, the guarded metrics sampler, and the runtime identity — reports said `node` 24.15.0 for -// Deno 2.8.3. - -export type BugseeDenoLaunchOptions = BugseeServerLaunchOptions; - -export const launch: (appToken: string, options?: BugseeDenoLaunchOptions) => Bugsee = - createServerLaunch(launchCore); - -/** Stop the running client (if any) and launch again with the same token, re-wiring the on-by-default - * extensions; `options` replace the previous launch options when given. */ -export const relaunch = (options?: BugseeDenoLaunchOptions): Promise => - relaunchWith(launch, options, options?.carrier); diff --git a/packages/bugsee/src/export-parity.test-d.ts b/packages/bugsee/src/export-parity.test-d.ts index 1ff2b4919..f9220fa39 100644 --- a/packages/bugsee/src/export-parity.test-d.ts +++ b/packages/bugsee/src/export-parity.test-d.ts @@ -5,7 +5,6 @@ import type * as Browser from './index'; import type * as Bun from './index.bun'; -import type * as Deno from './index.deno'; import type * as EdgeLight from './index.edge-light'; import type * as Node from './index.node'; import type * as Worker from './index.worker'; @@ -15,7 +14,6 @@ type Entry = | typeof Browser | typeof Node | typeof Bun - | typeof Deno | typeof EdgeLight | typeof Worker | typeof Workerd; @@ -51,16 +49,6 @@ export type BunTypes = [ Bun.LifecycleEventType, Bun.ReportAttachmentInput, ]; -export type DenoTypes = [ - Deno.DefaultNetworkSanitizer, - Deno.Span, - Deno.Transaction, - Deno.PerformanceFacade, - Deno.PerformanceApi, - Deno.LifecycleEventsListener, - Deno.LifecycleEventType, - Deno.ReportAttachmentInput, -]; export type EdgeLightTypes = [ EdgeLight.DefaultNetworkSanitizer, EdgeLight.Span, @@ -108,7 +96,6 @@ export type LifecycleListenerOptions = [ ListenerOption, ListenerOption, ListenerOption, - ListenerOption, ListenerOption, ListenerOption, ListenerOption, diff --git a/packages/bugsee/src/export-parity.test.ts b/packages/bugsee/src/export-parity.test.ts index ce46a21fb..a637aca29 100644 --- a/packages/bugsee/src/export-parity.test.ts +++ b/packages/bugsee/src/export-parity.test.ts @@ -1,13 +1,12 @@ import { describe, expect, it } from 'vitest'; import * as browserEntry from './index'; import * as bunEntry from './index.bun'; -import * as denoEntry from './index.deno'; import * as edgeEntry from './index.edge-light'; import * as nodeEntry from './index.node'; import * as workerEntry from './index.worker'; import * as workerdEntry from './index.workerd'; -// EXPORT PARITY across the seven umbrella entries (review O5). Which entry a user gets depends on a bundler +// EXPORT PARITY across the six umbrella entries (review O5). Which entry a user gets depends on a bundler // condition they never see, so a name that exists on one entry and not another is a runtime-only surprise // ("works on node, `undefined is not a function` on the edge"). Every name below is part of the public API // every runtime must expose. Type-only exports cannot be seen here; they are pinned in @@ -16,7 +15,6 @@ const entries = { browser: browserEntry, node: nodeEntry, bun: bunEntry, - deno: denoEntry, 'edge-light': edgeEntry, worker: workerEntry, workerd: workerdEntry, @@ -51,7 +49,7 @@ describe('public API export parity across the umbrella entries', () => { }); it('the server-side entries expose the same lifecycle surface as the browser entry', () => { - for (const entry of [nodeEntry, bunEntry, denoEntry]) { + for (const entry of [nodeEntry, bunEntry]) { expect(entry.getStatus).toBe(browserEntry.getStatus); expect(entry.BugseeStatus).toBe(browserEntry.BugseeStatus); } diff --git a/packages/bugsee/src/index.deno.ts b/packages/bugsee/src/index.deno.ts deleted file mode 100644 index bcfb1940b..000000000 --- a/packages/bugsee/src/index.deno.ts +++ /dev/null @@ -1,41 +0,0 @@ -// bugsee — the DENO entry (selected via the package `exports` "deno" condition, listed BEFORE "node" -// because Deno sets both). Re-exports the server SDK surface + the umbrella launch() bound to -// @bugsee/deno's composition root, so the Deno-specific defaults are not silently lost. See ./deno. - -// The built-in network redaction, for composing with a custom `setNetworkEventFilter` (which REPLACES the -// default sanitizer rather than layering on it). -export { type DefaultNetworkSanitizer, getDefaultNetworkSanitizer } from '@bugsee/capture'; -// Manual-instrumentation argument types — the curated public surface every adapter re-exports so users -// can type their own event()/addBreadcrumb()/logException() calls without reaching into @bugsee/core. -export type { - AttributeValue, - Breadcrumb, - BreadcrumbInput, - LogExceptionOptions, - ReportAttachmentInput, - UploadOptions, -} from '@bugsee/core'; -// Lifecycle events: the listener type + the event-name constants for `setLifecycleEventsListener`. -// Helper form of writing `report.userAttachments` from `ReportHandler.before` (Android `Report.addAttachment`). -export { - addReportAttachment, - LifecycleEvents, - type LifecycleEventsListener, - type LifecycleEventType, -} from '@bugsee/core'; -export type { BugseeSpanProcessor } from '@bugsee/opentelemetry'; -// The performance facade types (the top-level startTransaction/startSpan/getActiveSpan calls exist on every -// entry, so their types must too). -export type { - PerformanceApi, - PerformanceFacade, - Span, - SpanStatus, - StartTransactionOptions, - Transaction, - TransactionNameSource, -} from '@bugsee/performance'; -export { type BugseeDenoLaunchOptions, launch, relaunch } from './deno'; -export type { Bugsee, BugseeServerLaunchOptions } from './server-launch'; -export { BugseeStatus, getStatus } from './status'; -export type { UmbrellaExtensionOptions } from './wire'; diff --git a/packages/bugsee/src/lifecycle-exports.test.ts b/packages/bugsee/src/lifecycle-exports.test.ts index caba6bf9e..3f50e107a 100644 --- a/packages/bugsee/src/lifecycle-exports.test.ts +++ b/packages/bugsee/src/lifecycle-exports.test.ts @@ -2,7 +2,6 @@ import { addReportAttachment, BugseeStatus, LifecycleEvents } from '@bugsee/core import { describe, expect, it } from 'vitest'; import * as browserEntry from './index'; import * as bunEntry from './index.bun'; -import * as denoEntry from './index.deno'; import * as edgeEntry from './index.edge-light'; import * as nodeEntry from './index.node'; import * as workerEntry from './index.worker'; @@ -15,7 +14,6 @@ describe('LifecycleEvents is re-exported from every umbrella entry', () => { browser: browserEntry, node: nodeEntry, bun: bunEntry, - deno: denoEntry, 'edge-light': edgeEntry, worker: workerEntry, workerd: workerdEntry, @@ -31,7 +29,6 @@ const entries = { browser: browserEntry, node: nodeEntry, bun: bunEntry, - deno: denoEntry, 'edge-light': edgeEntry, worker: workerEntry, workerd: workerdEntry, diff --git a/packages/bugsee/src/node.ts b/packages/bugsee/src/node.ts index f821ad93a..145bf9c34 100644 --- a/packages/bugsee/src/node.ts +++ b/packages/bugsee/src/node.ts @@ -3,8 +3,8 @@ import { launchCore } from '@bugsee/node'; import { type Bugsee, type BugseeServerLaunchOptions, createServerLaunch } from './server-launch'; // The `bugsee` umbrella launch() for NODE — the batteries-included server entry, selected via the package -// `exports` "node" condition. The composition itself lives in ./server-launch, shared with the bun and deno -// entries; this file is only the binding to @bugsee/node's composition root. +// `exports` "node" condition. The composition itself lives in ./server-launch, shared with the bun +// entry; this file is only the binding to @bugsee/node's composition root. export type BugseeNodeLaunchOptions = BugseeServerLaunchOptions; diff --git a/packages/bugsee/src/public-surface.test-d.ts b/packages/bugsee/src/public-surface.test-d.ts index 442d46e14..7ba82ed7b 100644 --- a/packages/bugsee/src/public-surface.test-d.ts +++ b/packages/bugsee/src/public-surface.test-d.ts @@ -50,23 +50,10 @@ import type { BugseeServerLaunchOptions as BunServerOptions, UmbrellaExtensionOptions as BunUmbrella, } from './index.bun'; -import type { - BugseeServerLaunchOptions as DenoServerOptions, - UmbrellaExtensionOptions as DenoUmbrella, -} from './index.deno'; import type { BugseeServerLaunchOptions as NodeServerOptions, UmbrellaExtensionOptions as NodeUmbrella, } from './index.node'; -export const nameableServerOptions: [NodeServerOptions, BunServerOptions, DenoServerOptions] = [ - {}, - {}, - {}, -]; -export const nameableUmbrellaOptions: [BrowserUmbrella, NodeUmbrella, BunUmbrella, DenoUmbrella] = [ - {}, - {}, - {}, - {}, -]; +export const nameableServerOptions: [NodeServerOptions, BunServerOptions] = [{}, {}]; +export const nameableUmbrellaOptions: [BrowserUmbrella, NodeUmbrella, BunUmbrella] = [{}, {}, {}]; diff --git a/packages/bugsee/src/relaunch-options.test.ts b/packages/bugsee/src/relaunch-options.test.ts index cf2996db8..c96cae082 100644 --- a/packages/bugsee/src/relaunch-options.test.ts +++ b/packages/bugsee/src/relaunch-options.test.ts @@ -45,7 +45,6 @@ const INTERFACES: Array<[string, string, string]> = [ ['cloudflare', 'src/launch-config.ts', 'BugseeWorkerConfig'], ['cloudflare', 'src/launch.ts', 'launch'], ['bun', 'src/launch.ts', 'launch'], - ['deno', 'src/launch.ts', 'launch'], ]; function optionKeys(pkg: string, file: string, name: string): string[] { @@ -122,7 +121,7 @@ function optionKeys(pkg: string, file: string, name: string): string[] { * so a relaunch builds a fresh one; * - `captureNonce`, `controlNonce`, `otelExportHeaders` and `otelExportUrl` are secrets or per-launch * credentials: never kept (`setCarrierLastLaunch` stores only the kept list); - * - `systemTraceProducers` (node/bun/deno) holds STATEFUL producer instances: a producer's `start()` is a + * - `systemTraceProducers` (node/bun) holds STATEFUL producer instances: a producer's `start()` is a * no-op while it is already started, so an instance still running on another client would silently no-op * on the new one, and its trackers stay bound to the scheduler/onError of the launch that built them. A * relaunch therefore builds the runtime's fresh default set; @@ -268,13 +267,13 @@ describe('relaunch() option classification', { } }); - it('reaches the framework adapters and the Bun / Deno / Cloudflare launches', () => { + it('reaches the framework adapters and the Bun / Cloudflare launches', () => { expect(all.get('onSpanProcessor')).toContain('nextjs:NextjsServerOptions'); expect(all.get('setupOtelProvider')).toContain('nextjs:NextjsServerOptions'); expect(all.get('injectTraceMeta')).toContain('nuxt:InstallBugseeNitroOptions'); expect(all.get('flushTimeoutMs')).toContain('nuxt:InstallBugseeNitroEdgeOptions'); expect(all.get('appToken')).toContain('cloudflare:BugseeWorkerConfig'); - expect(all.get('transport')).toEqual(expect.arrayContaining(['bun:launch', 'deno:launch'])); + expect(all.get('transport')).toEqual(expect.arrayContaining(['bun:launch'])); expect(all.get('transport')).toContain('cloudflare:launch'); expect(all.get('endpoint')).toEqual( expect.arrayContaining(['astro:AstroServerOptions', 'remix:RemixServerOptions']), diff --git a/packages/bugsee/src/server-entries.test.ts b/packages/bugsee/src/server-entries.test.ts index 17c8aefd9..252e9cfde 100644 --- a/packages/bugsee/src/server-entries.test.ts +++ b/packages/bugsee/src/server-entries.test.ts @@ -2,18 +2,17 @@ import type { Clock, HttpRequestOptions, HttpResponse, HttpTransport } from '@bu import type { Bugsee, NodeRuntime } from '@bugsee/node'; import { afterEach, describe, expect, it, vi } from 'vitest'; import { launch as launchBun, relaunch as relaunchBun } from './bun'; -import { launch as launchDeno, relaunch as relaunchDeno } from './deno'; import { launch as launchNode, relaunch as relaunchNode } from './node'; import { BugseeStatus, getStatus } from './status'; // WAVE 3b.1 / 4.1 — the umbrella's three SERVER entries. // -// The umbrella had only `browser` / `node` / `default` conditions, so Bun and Deno — which set `node` too — +// The umbrella had only `browser` / `node` / `default` conditions, so Bun — which sets `node` too — // resolved to `@bugsee/node`. A customer on the documented single-install path silently lost every // runtime-specific default: `@bugsee/bun` supplies the `Bun.serve` interceptor (idiomatic // `Bun.serve({fetch})` apps bypass node:http entirely, so they were NOT instrumented at all), a guarded // perf_hooks metrics sampler, and the runtime identity. Measured through the real e2e harness before the -// fix: Bun 1.3.14 reported as `node` 24.3.0, Deno 2.8.3 as `node` 24.15.0. +// fix: Bun 1.3.14 reported as `node` 24.3.0. // // These run under Node — which is exactly the point of a condition-selected entry: only the runtime that // resolves it ever executes it, so nothing else in the suite would ever load these two files. They assert @@ -100,17 +99,13 @@ describe('the umbrella server entries bind their OWN runtime', () => { expect((await runtimeFromWire(launchBun)).type).toBe('bun'); }); - it('the deno entry runs @bugsee/deno’s composition root', async () => { - expect((await runtimeFromWire(launchDeno)).type).toBe('deno'); - }); - it('the node entry still runs @bugsee/node’s — the canary', async () => { // Without this, "each entry binds its own" would also be satisfied by all three binding to bun. expect((await runtimeFromWire(launchNode)).type).toBe('node'); }); it('every entry returns a usable client', () => { - for (const launch of [launchBun, launchDeno, launchNode]) { + for (const launch of [launchBun, launchNode]) { const client = track(launch('tok', base(recordingTransport().fn))); expect(typeof client.logException).toBe('function'); expect(typeof client.stop).toBe('function'); @@ -122,7 +117,6 @@ describe('the umbrella server entries relaunch through their OWN composition roo it.each([ ['node', launchNode, relaunchNode], ['bun', launchBun, relaunchBun], - ['deno', launchDeno, relaunchDeno], ] as const)('%s: relaunch returns a fresh client of the same runtime and status follows', async (type, launch, relaunch) => { const { fn, sessions } = recordingTransport(); const carrier = {}; diff --git a/packages/bugsee/src/server-launch.ts b/packages/bugsee/src/server-launch.ts index 97427a63a..b9de61aa1 100644 --- a/packages/bugsee/src/server-launch.ts +++ b/packages/bugsee/src/server-launch.ts @@ -3,12 +3,12 @@ import type { PerformanceFacade } from '@bugsee/performance'; import { withPerformanceFacade } from './performance-facade'; import { type UmbrellaExtensionOptions, wireUmbrella } from './wire'; -// The shared umbrella launch() for every SERVER runtime — node, bun and deno. +// The shared umbrella launch() for every SERVER runtime — node and bun. // -// All three run the same composition: a platform `launchCore`, then the on-by-default extensions via +// Both run the same composition: a platform `launchCore`, then the on-by-default extensions via // `wireUmbrella`. Only the `launchCore` differs, and only in its defaults — Bun swaps in the Bun identity -// probe, a guarded perf_hooks sampler and the `Bun.serve` interceptor; Deno the equivalents for `Deno.serve`. -// Factoring it here is what keeps the three entries from drifting, which matters because the drift is +// probe, a guarded perf_hooks sampler and the `Bun.serve` interceptor. +// Factoring it here is what keeps the entries from drifting, which matters because the drift is // invisible: they are selected by `exports` conditions, so only the runtime that resolves a given entry // ever executes it. // @@ -33,8 +33,8 @@ export function createServerLaunch( // No internals → a prior launch already owns the process singleton (and already wired the extensions). if (internals === undefined) return withPerformanceFacade(client); // Process start = now − uptime. Reached via globalThis (no node:process import → no node types needed); - // these entries only run on server runtimes, where process.uptime always exists (Bun and Deno both - // provide it through their node-compat layers). + // these entries only run on server runtimes, where process.uptime always exists (Bun + // provides it through its node-compat layer). const startupAtMs = options.appStartTimeMs ?? Date.now() - diff --git a/packages/bugsee/src/wire.ts b/packages/bugsee/src/wire.ts index 2eb09d870..47cd4eba7 100644 --- a/packages/bugsee/src/wire.ts +++ b/packages/bugsee/src/wire.ts @@ -255,7 +255,7 @@ export function wireUmbrella( }); // The OTLP instrumentation scope name is `com.bugsee./`. The SDK token // follows telemetry.sdk.language: `webjs` on the browser, `nodejs` on the node-family runtimes - // (node/bun/deno all run the node umbrella entry, pageload:false). The provider here is `performance`. + // (node/bun both run the node umbrella entry, pageload:false). The provider here is `performance`. const scopeName = `com.bugsee.${platform.pageload ? 'webjs' : 'nodejs'}/performance`; // Produce: when an OTLP endpoint is configured, TEE the drained batch to it too (Bugsee still receives // it). The internal-tagged transport keeps the SDK's own export out of network capture (self-isolation). diff --git a/packages/bugsee/tsup.config.ts b/packages/bugsee/tsup.config.ts index c814e89a0..cadd87393 100644 --- a/packages/bugsee/tsup.config.ts +++ b/packages/bugsee/tsup.config.ts @@ -11,7 +11,6 @@ export default defineConfig({ 'src/index.ts', 'src/index.node.ts', 'src/index.bun.ts', - 'src/index.deno.ts', 'src/index.workerd.ts', 'src/index.edge-light.ts', 'src/index.worker.ts', diff --git a/packages/bun/src/launch.ts b/packages/bun/src/launch.ts index 41e67031f..b4061597d 100644 --- a/packages/bun/src/launch.ts +++ b/packages/bun/src/launch.ts @@ -25,7 +25,7 @@ export function launchCore(appToken: string, options: BugseeLaunchOptions = {}): // JSC's heap statistics are not a V8 ceiling (`limit - used` is meaningless; ~1000x Node's cost per call), // so the V8 heap traces are omitted here. measuresV8Heap: false, - // `process.constrainedMemory()` is a cgroup cap: measured real on Linux (Bun 1.4.4 / Deno 2.8.3 under `docker -m`), + // `process.constrainedMemory()` is a cgroup cap: measured real on Linux (Bun 1.4.4 under `docker -m`), // while elsewhere there is no cap to report (Bun answers total RAM on macOS), so the trace is gated to Linux. measuresConstrainedMemory: process.platform === 'linux', // Bun < 1.3.13's `os.freemem()` is not MemAvailable on Linux, so `ram_system_free` reads /proc/meminfo @@ -44,8 +44,7 @@ export function launchCore(appToken: string, options: BugseeLaunchOptions = {}): // LOCAL VARIABLES ARE OFF HERE, after `...options` so a caller cannot switch them on. Measured on // Bun 1.4.0: `Debugger.enable` is REFUSED — `Inspector method "Debugger.enable" requires an active // inspector (call inspector.open() first)` — so no pause ever arrives and the capture is inert. - // Unlike Deno this is safe rather than dangerous (nothing freezes), but an option that is accepted - // and silently does nothing is still a lie to whoever set it. + // Nothing freezes, but an option that is accepted and silently does nothing is still a lie to whoever set it. // // Reversible the moment Bun implements the Debugger domain without `inspector.open()`; opening one // ourselves is not an option, since that exposes a debugger port in a production process. diff --git a/packages/capture/README.md b/packages/capture/README.md index 1076f53c0..0792f7bd7 100644 --- a/packages/capture/README.md +++ b/packages/capture/README.md @@ -13,7 +13,7 @@ This is an internal building block of the Bugsee SDK, not intended to be install - The default network sanitizer and the outgoing-request decorator registry (used for trace propagation). - Runtime-agnostic: platform packages add the runtime-specific sources (XHR, `node:http`, global error handlers). -It is used by `@bugsee/browser`, `@bugsee/node`, `@bugsee/bun`, `@bugsee/deno`, `@bugsee/webworker`, `@bugsee/vercel-edge`, `@bugsee/webview`, the backend adapters and the umbrella. Its API is internal and may change between releases. +It is used by `@bugsee/browser`, `@bugsee/node`, `@bugsee/bun`, `@bugsee/webworker`, `@bugsee/vercel-edge`, `@bugsee/webview`, the backend adapters and the umbrella. Its API is internal and may change between releases. ## Links diff --git a/packages/capture/src/absolutize-url.test.ts b/packages/capture/src/absolutize-url.test.ts index be0352b2b..ff9265700 100644 --- a/packages/capture/src/absolutize-url.test.ts +++ b/packages/capture/src/absolutize-url.test.ts @@ -68,7 +68,7 @@ describe('resolveBaseUrl — the base is the one the RUNTIME itself would use', expect(resolveBaseUrl({ location: { href: '' } })).toBeUndefined(); }); - it('returns undefined in a bare realm (node/bun/deno: no document, no location)', () => { + it('returns undefined in a bare realm (node/bun: no document, no location)', () => { expect(resolveBaseUrl(bareRealm())).toBeUndefined(); }); @@ -170,7 +170,7 @@ describe('absolutizeUrl — safety valve: a WRONG origin is worse than a missing it('does not even construct a URL when there is no base', () => { // The `base === undefined` guard is NOT redundant with the catch below it, even though both yield // the raw string: without the guard, `new URL(url, undefined)` THROWS on every call, and the - // location-less hosts (node/bun/deno) are the ones where every single captured request takes this + // location-less hosts (node/bun) are the ones where every single captured request takes this // path. Constructing-and-throwing per request is a cost that never shows up in an output assertion, // so it is asserted directly here. type Ctor = new (url: string, base?: string) => { href: string }; @@ -319,7 +319,7 @@ describe('absolutizeUrl — the default probe reads the real globals', () => { }); it('returns the raw url on a bare host (node: no document, no location)', () => { - // Guards the server tiers: node/bun/deno define neither global, so an incoming request target + // Guards the server tiers: node/bun define neither global, so an incoming request target // captured as `/api/x` must stay `/api/x` — there is no client origin to attach to it. expect((globalThis as unknown as { document?: unknown }).document).toBeUndefined(); expect((globalThis as unknown as { location?: unknown }).location).toBeUndefined(); diff --git a/packages/capture/src/absolutize-url.ts b/packages/capture/src/absolutize-url.ts index 65a48b5fe..6aedfbc62 100644 --- a/packages/capture/src/absolutize-url.ts +++ b/packages/capture/src/absolutize-url.ts @@ -66,7 +66,7 @@ function asBase(value: unknown): string | undefined { * 2. `location.href` — a DEDICATED or SERVICE worker, which has no `document`. There, `location.href` * is the worker SCRIPT's URL, and that is genuinely what the worker's own relative `fetch()` calls * resolve against. - * 3. `undefined` — node/bun/deno and any other location-less host. No origin is invented; the caller + * 3. `undefined` — node/bun and any other location-less host. No origin is invented; the caller * keeps the raw string. This is what keeps SERVER capture honest: an incoming request target is * captured as `/api/x` and stays `/api/x`, because there is no client origin to attach to it. * diff --git a/packages/capture/src/capture-state-producer.ts b/packages/capture/src/capture-state-producer.ts index f34c6d6e3..09d658906 100644 --- a/packages/capture/src/capture-state-producer.ts +++ b/packages/capture/src/capture-state-producer.ts @@ -16,7 +16,7 @@ import { TraceProducerBase } from './trace-producer'; // states, because a held `low_disk_space` for a capture that never started would be re-recorded as if it were true. // // WHO BUILDS IT. Only a host that HAS visual capture: the browser with rrweb replay on, Electron main with pixel -// video. Node/Bun/Deno never build one (an `active` there would assert a capture that is not running), and WebViews and +// video. Node/Bun never build one (an `active` there would assert a capture that is not running), and WebViews and // Electron renderers must not (the native host / main writes it). `active`/`blackout` are written only after // `setVisualCapture(true)` (the host says the recorder really started), and so do the disk states. // diff --git a/packages/capture/src/network-provider.test.ts b/packages/capture/src/network-provider.test.ts index 9c1f78c29..66bc55976 100644 --- a/packages/capture/src/network-provider.test.ts +++ b/packages/capture/src/network-provider.test.ts @@ -832,7 +832,7 @@ describe('network URL absolutization', () => { expect(captured.url).toBe('https://app.example.com/api/x'); }); - it('leaves the URL relative on a location-less host (node/bun/deno server capture)', async () => { + it('leaves the URL relative on a location-less host (node/bun server capture)', async () => { // node:http incoming requests fold into this same provider via `additionalSources` and carry a // path-only target. There is no client origin on a server, and inventing one would be a worse // defect than the missing one — so `/api/x` must stay `/api/x`. diff --git a/packages/core/README.md b/packages/core/README.md index c895c8bf1..2300dba29 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -11,9 +11,9 @@ This is an internal building block of the Bugsee SDK, not intended to be install - The `Client` and the launch-option resolver. - The capture aggregator, capture stores, bundle writer and durable bundle queue. - Trigger and upload pipelines, plus the interceptor and event-emitter base classes. -- Runtime-portable: it reaches runtime globals only through injected seams, so the same code runs in browsers, Node.js, Bun, Deno and edge runtimes. +- Runtime-portable: it reaches runtime globals only through injected seams, so the same code runs in browsers, Node.js, Bun and edge runtimes. -Every platform and adapter package (`@bugsee/browser`, `@bugsee/node`, `@bugsee/bun`, `@bugsee/deno`, `@bugsee/electron`, the framework adapters and others) depends on it. Its API is internal and may change between releases. +Every platform and adapter package (`@bugsee/browser`, `@bugsee/node`, `@bugsee/bun`, `@bugsee/electron`, the framework adapters and others) depends on it. Its API is internal and may change between releases. ## Links diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index d6e09fcd4..11d33339b 100644 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -576,7 +576,7 @@ export interface CreateClientOptions { /** * Runtime stack parser used to build the structured `crash.json` from a thrown Error's stack. The * browser tier injects its multi-engine (V8 + SpiderMonkey + JavaScriptCore) parser; V8 runtimes - * (node/bun/deno + Chromium) get the default {@link parseV8Stack}. Absent → crash.json still builds via + * (node/bun + Chromium) get the default {@link parseV8Stack}. Absent → crash.json still builds via * the V8 default. */ stackParser?: (stack: string) => StackFrame[]; diff --git a/packages/core/src/relaunch-timer.test.ts b/packages/core/src/relaunch-timer.test.ts index 9e6c8877e..2d7e22a95 100644 --- a/packages/core/src/relaunch-timer.test.ts +++ b/packages/core/src/relaunch-timer.test.ts @@ -3,7 +3,7 @@ import { setCarrierClient, setCarrierLastLaunch } from './carrier'; import { relaunchWith } from './relaunch'; // The deadline timer of a bounded relaunch must NEVER keep a process alive: -// a Node/Bun/Deno process whose last client stopped would otherwise sit out the full 5 s default waiting for +// a Node/Bun process whose last client stopped would otherwise sit out the full 5 s default waiting for // a deadline nobody needs. Two properties, both observed through the real `relaunchWith`: // 1. the timer handle is `unref()`ed when the runtime offers it (and a runtime whose handle has no `unref`, // i.e. a browser's number, works the same); diff --git a/packages/core/src/stack.ts b/packages/core/src/stack.ts index dee114fad..662f78291 100644 --- a/packages/core/src/stack.ts +++ b/packages/core/src/stack.ts @@ -1,5 +1,5 @@ // V8 stack-trace parsing (frame-path scrubbing). Pure string work, so it lives -// in core and is shared by every V8 runtime (node/bun/deno + chromium browsers); the browser tier +// in core and is shared by every V8 runtime (node/bun + chromium browsers); the browser tier // adds SpiderMonkey/JavaScriptCore parsers and a runtime-dispatching parseStack on top. The other // report-path steps (ignoreErrors / denyUrls / shape-redaction on the message / errorMessageFilter) are // config-driven and belong to the report path, not this pure parser. diff --git a/packages/deno/LICENSE b/packages/deno/LICENSE deleted file mode 100644 index e24ee0244..000000000 --- a/packages/deno/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2026 Bugsee - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/deno/README.md b/packages/deno/README.md deleted file mode 100644 index 3b02aa599..000000000 --- a/packages/deno/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# @bugsee/deno - -The Bugsee SDK for Deno: crash and error capture, console and network capture, incoming `Deno.serve` request instrumentation, and on-disk capture with crash recovery. - -Part of the Bugsee JavaScript SDK (public beta, 0.1.0-beta.x). - -Install this package directly in Deno projects. It runs the same pipeline as `@bugsee/node` through Deno's `node:` compatibility layer and only changes how the runtime is identified in reports (`deno` and its version). - -## Install - -```sh -deno add npm:@bugsee/deno -``` - -Requires Deno 2.0 or newer. Core capture works on 2.0. The CPU profiler and the hang detector depend on Deno's Node compatibility and disable themselves where it is missing; they are fully available on Deno 2.8 and newer. - -## Usage - -Call `launch()` at the top of your entry file. It returns the client directly (not a `Promise`). - -```ts -import { launch } from '@bugsee/deno'; - -const bugsee = launch('YOUR_APP_TOKEN', { appVersion: '1.0.0' }); -``` - -Run with the permissions the SDK needs: - -```sh -deno run --allow-net --allow-read --allow-write main.ts -``` - -`--allow-net` is for report upload. `--allow-read` and `--allow-write` are for on-disk capture and crash recovery (`dataDir`). If a permission is denied, the affected feature fails and the error goes to the `onError` callback instead of your app. - -## Options - -`launch(appToken, options)` accepts the same options as `@bugsee/node`. Common ones: - -- `appVersion`, `appBuild`, `appId`: identify your release in reports. -- `captureLogs`, `captureNetwork`, `captureNetworkBodies`: capture streams, all on by default. -- `maxRecordingTime`: rolling recording window in seconds (default 60). -- `dataDir`: where the on-disk capture buffer lives (default `/bugsee`). -- `instrumentIncomingRequests`: automatic `Deno.serve` request instrumentation (on by default). -- `onError`: receives errors the SDK itself hits, such as denied permissions. - -On Deno, local-variable capture (`captureLocalVariables`) is always off, and the event-loop lag traces are omitted, because Deno's debugger and event-loop APIs do not behave the way those features need. - -## Links - -- Repository: https://github.com/bugsee/bugsee-javascript/tree/main/packages/deno -- Bugsee: https://bugsee.com - -## License - -MIT. See the LICENSE file. diff --git a/packages/deno/package.json b/packages/deno/package.json deleted file mode 100644 index a768011d1..000000000 --- a/packages/deno/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "@bugsee/deno", - "version": "0.1.0-beta.5", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/bugsee/bugsee-javascript.git", - "directory": "packages/deno" - }, - "description": "Deno platform: re-exports @bugsee/node + Deno overrides", - "type": "module", - "main": "./src/index.ts", - "types": "./src/index.ts", - "exports": { - ".": { - "types": "./src/index.ts", - "import": "./src/index.ts" - } - }, - "files": [ - "dist" - ], - "sideEffects": false, - "scripts": { - "build": "tsup", - "typecheck": "tsc --noEmit", - "test": "vitest run", - "test:coverage": "vitest run --coverage" - }, - "dependencies": { - "@bugsee/capture": "workspace:*", - "@bugsee/core": "workspace:*", - "@bugsee/node": "workspace:*", - "@bugsee/node-utils": "workspace:*" - }, - "devDependencies": { - "@bugsee/util": "workspace:*", - "@types/node": "^22.20.5" - }, - "publishConfig": { - "main": "./dist/index.cjs", - "module": "./dist/index.js", - "types": "./dist/index.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - }, - "require": { - "types": "./dist/index.d.cts", - "default": "./dist/index.cjs" - } - } - }, - "access": "public" - } -} diff --git a/packages/deno/src/deno-serve-interceptor.test.ts b/packages/deno/src/deno-serve-interceptor.test.ts deleted file mode 100644 index eef106632..000000000 --- a/packages/deno/src/deno-serve-interceptor.test.ts +++ /dev/null @@ -1,180 +0,0 @@ -import type { BugseeClient } from '@bugsee/core'; -import { createNodeRequestContextStore, type FetchRequestLike } from '@bugsee/node'; -import { describe, expect, it, vi } from 'vitest'; -import { createDenoServeInterceptor } from './deno-serve-interceptor'; - -// A structural http.server transaction (avoids a @bugsee/performance dep in this Deno package). -const fakeTxn = () => ({ - getTraceId: () => 'trace-1', - getSpanId: () => 'span-1', - isSampled: () => true, - isFinished: vi.fn(() => false), - setName: vi.fn(), - setAttribute: vi.fn(), - // Required so server-instrument's F-4 manual-rename check (transaction.getAttributes()) runs for - // real instead of degrading via a defensive catch — see server-instrument.ts's `manuallyRenamed` read. - // `getAttributes` is a required Span member; a double omitting it does not satisfy the interface it - // claims, and used to be masked by an inner try/catch that has since been removed. - getAttributes: vi.fn(() => ({})), - finish: vi.fn(), -}); - -const fakeClient = (store?: ReturnType) => { - const txn = fakeTxn(); - const startTransaction = vi.fn(() => txn); - const client = { - getServiceProvider: () => ({ getImmediate: () => store }), - ext: () => ({ startTransaction }), - logException: vi.fn(() => Promise.resolve()), - } as unknown as BugseeClient; - return { client, txn, startTransaction }; -}; - -const makeReq = (method: string, url: string): FetchRequestLike => ({ - method, - url, - headers: { get: () => null }, -}); - -type Handler = (req: FetchRequestLike) => unknown; -// A fake Deno global whose serve() records the (options?, handler) it was handed. -const fakeDenoHost = () => { - const calls: Array<{ args: unknown[] }> = []; - const serve = vi.fn((...args: unknown[]) => { - calls.push({ args }); - return { shutdown: async () => {}, addr: { port: 0 } }; - }); - return { host: { Deno: { serve } }, serve, calls }; -}; - -// Pull the wrapped handler out of a recorded serve() call: it's the function arg (last positional) or -// options.handler. -const handlerOf = (call: { args: unknown[] }): Handler => { - const fn = call.args.find((a) => typeof a === 'function'); - if (fn) { - return fn as Handler; - } - return (call.args[0] as { handler: Handler }).handler; -}; - -describe('createDenoServeInterceptor', () => { - it.each([ - [ - 'handler-first Deno.serve(handler)', - (serve: (...a: unknown[]) => unknown, h: Handler) => serve(h), - ], - [ - 'options-first Deno.serve(options, handler)', - (serve: (...a: unknown[]) => unknown, h: Handler) => serve({ port: 0 }, h), - ], - [ - 'options-object Deno.serve({ handler })', - (serve: (...a: unknown[]) => unknown, h: Handler) => serve({ port: 0, handler: h }), - ], - ])('wraps the handler for the %s overload', async (_name, invoke) => { - const store = createNodeRequestContextStore(); - const { client, txn } = fakeClient(store); - const { host, calls } = fakeDenoHost(); - const ic = createDenoServeInterceptor({ - target: host, - getClient: () => client, - newContextId: () => 'deno-cid', - shouldReport: () => true, - }); - ic.install(); - - let ctxDuring: string | undefined; - const userHandler: Handler = async () => { - ctxDuring = store.getCurrent()?.contextId; - return { status: 200 }; - }; - invoke(host.Deno.serve, userHandler); - const wrapped = handlerOf(calls[0] as { args: unknown[] }); - const res = await wrapped(makeReq('GET', '/x')); - ic.uninstall(); - - expect(res).toEqual({ status: 200 }); - expect(ctxDuring).toBe('deno-cid'); // context (with the supplied id) active inside the native handler - expect(txn.finish).toHaveBeenCalledWith('OK'); - }); - - it('forwards traceResponse → the wrapped handler decorates its Response with the return headers', async () => { - const { client } = fakeClient(createNodeRequestContextStore()); - const { host, calls } = fakeDenoHost(); - const ic = createDenoServeInterceptor({ - target: host, - getClient: () => client, - traceResponse: { traceresponse: true, serverTiming: true }, - }); - ic.install(); - const set: Record = {}; - const userHandler: Handler = async () => ({ - status: 200, - headers: { - set: (n: string, v: string) => { - set[n] = v; - }, - }, - }); - host.Deno.serve(userHandler); - const wrapped = handlerOf(calls[0] as { args: unknown[] }); - await wrapped(makeReq('GET', '/x')); - ic.uninstall(); - expect(set).toEqual({ - traceresponse: '00-trace-1-span-1-01', - 'Server-Timing': 'traceparent;desc="00-trace-1-span-1-01"', - }); - }); - - it('writes NO return headers by default (traceResponse off)', async () => { - const { client } = fakeClient(createNodeRequestContextStore()); - const { host, calls } = fakeDenoHost(); - const ic = createDenoServeInterceptor({ target: host, getClient: () => client }); - ic.install(); - const set: Record = {}; - const userHandler: Handler = async () => ({ - status: 200, - headers: { - set: (n: string, v: string) => { - set[n] = v; - }, - }, - }); - host.Deno.serve(userHandler); - const wrapped = handlerOf(calls[0] as { args: unknown[] }); - await wrapped(makeReq('GET', '/x')); - ic.uninstall(); - expect(set).toEqual({}); - }); - - it('passes through serve() with no handler — options-only AND no-args — untouched', () => { - const { host, serve } = fakeDenoHost(); - const ic = createDenoServeInterceptor({ target: host }); - ic.install(); - host.Deno.serve({ port: 0 }); // options, no handler → passthrough - host.Deno.serve(); // no args → the `args[0] ?? {}` fallback → passthrough - ic.uninstall(); - expect(serve).toHaveBeenNthCalledWith(1, { port: 0 }); - expect(serve).toHaveBeenNthCalledWith(2); - }); - - it('self-skips when Deno is absent (install + uninstall are no-ops)', () => { - const ic = createDenoServeInterceptor({ target: {} }); - expect(() => { - ic.install(); - ic.uninstall(); - }).not.toThrow(); - }); - - it('restores the original Deno.serve on uninstall (idempotent)', () => { - const { host, serve } = fakeDenoHost(); - const ic = createDenoServeInterceptor({ target: host }); - ic.install(); - expect(host.Deno.serve).not.toBe(serve); // patched - ic.install(); // idempotent — does not re-wrap - ic.uninstall(); - expect(host.Deno.serve).toBe(serve); // restored - ic.uninstall(); // idempotent - expect(host.Deno.serve).toBe(serve); - }); -}); diff --git a/packages/deno/src/deno-serve-interceptor.ts b/packages/deno/src/deno-serve-interceptor.ts deleted file mode 100644 index eaf3b3a48..000000000 --- a/packages/deno/src/deno-serve-interceptor.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { - type FetchHandler, - type ServerInstallable, - type ServerInstrumentOptions, - wrapFetchHandler, -} from '@bugsee/node'; - -// Native Deno.serve instrumentation. Replaces -// `Deno.serve` to wrap its handler — across all overloads: `Deno.serve(handler)`, -// `Deno.serve(options, handler)`, and `Deno.serve({ handler, ... })` — via the shared `wrapFetchHandler`, -// so idiomatic Deno.serve apps (which bypass node:http) get a per-request context + http.server -// transaction. Self-skips when `Deno` is absent (e.g. unit tests on Node). A throw escaping the handler is -// captured + re-thrown (Deno turns it into a 500), verified by the spike on Deno 2.8. - -type DenoHandler = FetchHandler<[info?: unknown]>; -interface DenoServeOptions { - handler?: DenoHandler; - [key: string]: unknown; -} -type DenoServe = (...args: unknown[]) => unknown; -interface DenoLike { - serve: DenoServe; -} -interface DenoHost { - Deno?: DenoLike; -} - -export interface DenoServeInterceptorOptions extends ServerInstrumentOptions { - /** The host object exposing `Deno` (default `globalThis`). Injectable for tests. */ - target?: DenoHost; -} - -export function createDenoServeInterceptor( - options: DenoServeInterceptorOptions = {}, -): ServerInstallable { - const host = options.target ?? (globalThis as DenoHost); - const instrumentOptions: ServerInstrumentOptions = { - ...(options.getClient !== undefined ? { getClient: options.getClient } : {}), - ...(options.newContextId !== undefined ? { newContextId: options.newContextId } : {}), - ...(options.shouldReport !== undefined ? { shouldReport: options.shouldReport } : {}), - ...(options.traceResponse !== undefined ? { traceResponse: options.traceResponse } : {}), - }; - const wrap = (handler: DenoHandler): DenoHandler => wrapFetchHandler(handler, instrumentOptions); - let installed = false; - let deno: DenoLike | undefined; - let original: DenoServe | undefined; - - return { - install() { - if (installed) { - return; - } - const target = host.Deno; - if (target === undefined || typeof target.serve !== 'function') { - return; // Deno absent — self-skip - } - installed = true; - deno = target; - original = target.serve; - const orig = original; - target.serve = function patchedServe(...args: unknown[]) { - if (typeof args[0] === 'function') { - return orig.call(this, wrap(args[0] as DenoHandler)); // Deno.serve(handler) - } - const serveOptions = (args[0] ?? {}) as DenoServeOptions; - if (typeof args[1] === 'function') { - return orig.call(this, serveOptions, wrap(args[1] as DenoHandler)); // Deno.serve(options, handler) - } - if (typeof serveOptions.handler === 'function') { - return orig.call(this, { ...serveOptions, handler: wrap(serveOptions.handler) }); // {handler} - } - return orig.apply(this, args); - }; - }, - uninstall() { - if (!installed || deno === undefined || original === undefined) { - return; - } - installed = false; - deno.serve = original; - deno = undefined; - original = undefined; - }, - }; -} diff --git a/packages/deno/src/environment.test.ts b/packages/deno/src/environment.test.ts deleted file mode 100644 index 11d7f70b9..000000000 --- a/packages/deno/src/environment.test.ts +++ /dev/null @@ -1,55 +0,0 @@ -import process from 'node:process'; -import { realSystemProbe } from '@bugsee/node'; -import { afterEach, describe, expect, it } from 'vitest'; -import { createDenoSystemProbe, denoSystemProbe } from './environment'; - -afterEach(() => { - delete (globalThis as { Deno?: unknown }).Deno; -}); - -describe('createDenoSystemProbe — runtime identity', () => { - it('reports platform.type "deno"', () => { - expect(createDenoSystemProbe('2.1.4', '22.0.0').platformType()).toBe('deno'); - }); - - it('uses the Deno version when present', () => { - expect(createDenoSystemProbe('2.1.4', '22.0.0').runtimeVersion()).toBe('2.1.4'); - }); - - it('falls back to the node-compat version when Deno is absent (e.g. run under Node)', () => { - expect(createDenoSystemProbe(undefined, '22.0.0').runtimeVersion()).toBe('22.0.0'); - }); - - it('reads the live Deno.version.deno when the global is present', () => { - (globalThis as { Deno?: unknown }).Deno = { version: { deno: '2.0.0' } }; - expect(createDenoSystemProbe(undefined, '22.0.0').runtimeVersion()).toBe('2.0.0'); - }); -}); - -describe('denoSystemProbe — defaults + reuse', () => { - it('defaults its version to the live Deno / node-compat fallback', () => { - // Under Node/Vitest the `Deno` global is absent → falls back to the node-compat version. - expect(denoSystemProbe.platformType()).toBe('deno'); - expect(denoSystemProbe.runtimeVersion()).toBe(process.versions.node); - }); - - it("reuses node's real OS/CPU/memory/locale readers (Deno is node-API-compatible)", () => { - expect(denoSystemProbe.osType()).toBe(realSystemProbe.osType()); - expect(denoSystemProbe.osRelease()).toBe(realSystemProbe.osRelease()); - expect(denoSystemProbe.machine()).toBe(realSystemProbe.machine()); - expect(denoSystemProbe.cpuCount()).toBe(realSystemProbe.cpuCount()); - expect(denoSystemProbe.totalMemory()).toBe(realSystemProbe.totalMemory()); - expect(typeof denoSystemProbe.utcOffsetMinutes()).toBe('number'); - expect(typeof denoSystemProbe.locale()).toBe('string'); - }); -}); - -describe('denoSystemProbe — uptime', () => { - it("inherits node's real process.uptime() reader (app.uptime_s would silently vanish otherwise)", () => { - expect(typeof denoSystemProbe.uptimeSeconds).toBe('function'); - const up = denoSystemProbe.uptimeSeconds?.(); - expect(typeof up).toBe('number'); - expect(up as number).toBeGreaterThan(0); - expect(up as number).toBeLessThan(process.uptime() + 1); - }); -}); diff --git a/packages/deno/src/environment.ts b/packages/deno/src/environment.ts deleted file mode 100644 index 176bc8527..000000000 --- a/packages/deno/src/environment.ts +++ /dev/null @@ -1,30 +0,0 @@ -import process from 'node:process'; -import { realSystemProbe, type SystemProbe } from '@bugsee/node'; - -// The Deno SystemProbe. Deno (2+) runs on a node-compatible API surface, so the OS/CPU/memory/locale reads -// reuse @bugsee/node's realSystemProbe verbatim — only the runtime IDENTITY differs: platform.type 'deno' -// and platform.version from Deno's own version (`Deno.version.deno`), with a node-compat fallback. The -// version is injectable so both branches are testable under Node (where the `Deno` global is absent). - -/** Read the live `Deno.version.deno`, or undefined when not running under Deno. */ -const liveDenoVersion = (): string | undefined => { - try { - return (globalThis as unknown as { Deno: { version: { deno: string } } }).Deno.version.deno; - } catch { - return undefined; // not running under Deno (the global / version is absent) - } -}; - -export function createDenoSystemProbe( - denoVersion: string | undefined = liveDenoVersion(), - nodeVersion: string = process.versions.node, -): SystemProbe { - return { - ...realSystemProbe, - platformType: () => 'deno', - runtimeVersion: () => denoVersion ?? nodeVersion, - }; -} - -/** The default Deno probe over the live `Deno` global. */ -export const denoSystemProbe: SystemProbe = createDenoSystemProbe(); diff --git a/packages/deno/src/index.exports.test.ts b/packages/deno/src/index.exports.test.ts deleted file mode 100644 index 703762c97..000000000 --- a/packages/deno/src/index.exports.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { getDefaultNetworkSanitizer } from '@bugsee/capture'; -import { addReportAttachment, BugseeStatus, LifecycleEvents } from '@bugsee/core'; -import { describe, expect, it } from 'vitest'; -import * as entry from './index'; - -// The package barrel hands out the umbrella's value API. Loading it here also makes the barrel -// a COVERED file on a cold CI transform (see the note in @bugsee/node's index.test.ts). -describe('@bugsee/deno barrel: the shared value API', () => { - it('re-exports the same functions and constants as core / capture', () => { - expect(entry.addReportAttachment).toBe(addReportAttachment); - expect(entry.BugseeStatus).toBe(BugseeStatus); - expect(entry.LifecycleEvents).toBe(LifecycleEvents); - expect(entry.getDefaultNetworkSanitizer).toBe(getDefaultNetworkSanitizer); - }); - - it('exposes its own relaunch (rejects before any launch)', async () => { - await expect(entry.relaunch({ carrier: {} })).rejects.toThrow(/before launch/); - }); -}); diff --git a/packages/deno/src/index.ts b/packages/deno/src/index.ts deleted file mode 100644 index 817b0f835..000000000 --- a/packages/deno/src/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -// @bugsee/deno — Deno platform. Deno is node-API-compatible, so this package IS @bugsee/node with -// two Deno-specific overrides: launch()/launchCore() default the system probe (platform.type 'deno' + Deno -// version) and the system trace producers (createNodeSystemTraceProducers over partial perf_hooks, with the -// event-loop lag opted out). The full node surface is re-exported; the explicit launch/launchCore exports below -// shadow node's same-named exports. - -export * from '@bugsee/node'; -export { - createDenoServeInterceptor, - type DenoServeInterceptorOptions, -} from './deno-serve-interceptor'; -export { createDenoSystemProbe, denoSystemProbe } from './environment'; -// Deno's launch()/launchCore() — shadow the @bugsee/node ones re-exported by `export *` above. -export { launch, launchCore } from './launch'; -// Likewise `relaunch` re-runs THIS launch (the node one from `export *` would drop the runtime probe/gates). -export { relaunch } from './relaunch'; diff --git a/packages/deno/src/launch.test.ts b/packages/deno/src/launch.test.ts deleted file mode 100644 index af3f8b10e..000000000 --- a/packages/deno/src/launch.test.ts +++ /dev/null @@ -1,501 +0,0 @@ -import process from 'node:process'; -import { - type Clock, - createCaptureExporter, - createMemoryCaptureStore, - type HttpRequestOptions, - type HttpResponse, - type HttpTransport, - type Scheduler, -} from '@bugsee/core'; -import { - createNodeSystemTraceProducers, - type NodeRuntime, - processTrackerFor, - resetProcessTracker, - type SystemProbe, -} from '@bugsee/node'; -import { strFromU8, unzipSync } from '@bugsee/util'; -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { denoSystemProbe } from './environment'; -import { launch, launchCore } from './launch'; - -// The event-loop-lag OPT-OUT is pure WIRING from this tier: what the flag DOES (omitting the three lag -// traces rather than reporting zeros) is pinned behaviourally in -// `node/src/trace-producers.test.ts` (`measuresEventLoopDelay:false never constructs a histogram`). What only this tier can decide is that Deno is a runtime -// that must set it, so that is what is pinned here — against the call. -vi.mock('@bugsee/node', async (importOriginal) => { - const actual = await importOriginal(); - return { - ...actual, - createNodeSystemTraceProducers: vi.fn(actual.createNodeSystemTraceProducers), - }; -}); - -// --- fakes: no real process / network / timers -------------------------------------------------- - -function fakeProcess(): NodeRuntime { - const listeners = new Map void>>(); - const proc: NodeRuntime = { - on(event, listener) { - const list = listeners.get(event) ?? []; - list.push(listener); - listeners.set(event, list); - return proc; - }, - off(event, listener) { - listeners.set( - event, - (listeners.get(event) ?? []).filter((l) => l !== listener), - ); - return proc; - }, - exit: vi.fn(), - }; - return proc; -} - -const jsonBody = (o: unknown): Uint8Array => new Uint8Array(Buffer.from(JSON.stringify(o))); - -// A transport that satisfies the full upload path (session → issue → signed PUT) and records calls. -function uploadTransport() { - return vi.fn(async (url: string, _o: HttpRequestOptions = {}) => { - if (url.endsWith('/v2/sessions')) { - return { - status: 200, - headers: {}, - body: jsonBody({ access_token: 'a' }), - } satisfies HttpResponse; - } - if (url.endsWith('/v2/issues')) { - return { - status: 200, - headers: {}, - body: jsonBody({ endpoint: 'https://s3.test/put', issueId: 'i1', recordingId: 'r1' }), - } satisfies HttpResponse; - } - return { status: 200, headers: {}, body: new Uint8Array() } satisfies HttpResponse; - }); -} - -const fixedClock: Clock = { wallNow: () => 1000, monotonicNow: () => 0 }; -const fakeScheduler: Scheduler = { setInterval: () => 'h', clearInterval: () => {} }; -const memStore = () => createMemoryCaptureStore({ maxRecordingTimeMs: Number.POSITIVE_INFINITY }); - -const base = (over: Partial[1]> = {}): Parameters[1] => ({ - process: fakeProcess(), - transport: uploadTransport(), - clock: fixedClock, - scheduler: fakeScheduler, - captureNetwork: false, - captureSystemTraces: false, - detectHangs: false, // no real watchdog worker in unit tests - captureStore: memStore(), - carrier: {}, // fresh per launch → the per-process singleton guard never collides across tests - ...over, -}); - -// Every test starts from a clean factory spy, so a call recorded by an earlier launch can never satisfy -// (or break) a later test's assertion on the call count / argument. -beforeEach(() => { - vi.mocked(createNodeSystemTraceProducers).mockClear(); -}); - -const clients: Array<{ stop: (t?: number) => Promise }> = []; -afterEach(async () => { - await Promise.all(clients.splice(0).map((c) => c.stop())); - resetProcessTracker(); // the per-process ProcessTracker singleton must not carry one test's seams into the next - delete (globalThis as { __BUGSEE__?: unknown }).__BUGSEE__; -}); -const track = Promise }>(c: T): T => { - clients.push(c); - return c; -}; - -describe('@bugsee/deno launch', () => { - it('reports the Deno RUNTIME identity in the environment envelope', () => { - const { client, internals } = launchCore('tok', base()); - track(client); - expect(internals).toBeDefined(); - const env = internals?.getEnvironment(); - expect(env?.runtime.type).toBe('deno'); - expect(env?.runtime.version).toBe(process.versions.node); // Deno global absent under vitest → fallback - }); - - it('defaults the system probe to the Deno probe but lets the caller override it', () => { - const nodeProbe: SystemProbe = { - ...denoSystemProbe, - platformType: () => 'node', - runtimeVersion: () => '20.0.0', - }; - const { client, internals } = launchCore('tok', base({ systemProbe: nodeProbe })); - track(client); - // The caller-supplied probe wins over the Deno default (it spreads after it). - expect(internals?.getEnvironment().runtime.type).toBe('node'); - expect(internals?.getEnvironment().runtime.version).toBe('20.0.0'); - }); - - it('uploads a report carrying the Deno environment on the wire (end-to-end via the node composition)', async () => { - const transport = uploadTransport(); - const client = track(launch('tok', base({ transport }))); - await client.logException(new Error('boom')); - // The session create carries the environment … - expect(transport.mock.calls[0]?.[0]).toMatch(/\/v2\/sessions$/); - const session = JSON.parse( - String((transport.mock.calls[0]?.[1] as HttpRequestOptions).body), - ) as { environment: { runtime: { type: string } } }; - expect(session.environment.runtime.type).toBe('deno'); - // … and the actual report BUNDLE (the signed PUT zip) embeds the Deno environment in request.json. - const put = transport.mock.calls.find(([url]) => url === 'https://s3.test/put'); - expect(put).toBeDefined(); - const files = unzipSync((put?.[1] as HttpRequestOptions).body as Uint8Array); - const requestJson = JSON.parse(strFromU8(files['request.json'] as Uint8Array)) as { - environment: { runtime: { type: string; version: string } }; - }; - expect(requestJson.environment.runtime.type).toBe('deno'); - expect(requestJson.environment.runtime.version).toBe(process.versions.node); // node-compat fallback under vitest - }); - - it('detects the app version and build from the environment, and honours appIdentitySource', () => { - vi.stubEnv('BUGSEE_APP_VERSION', '6.4.0'); - vi.stubEnv('BUGSEE_APP_BUILD', 'b-17'); - try { - const detected = launchCore('tok', base()); - track(detected.client); - expect(detected.internals?.getEnvironment().app).toMatchObject({ - version: '6.4.0', - build: 'b-17', - }); - const sourced = launchCore( - 'tok', - base({ appIdentitySource: () => ({ version: '8.0.0' }), carrier: {} }), - ); - track(sourced.client); - expect(sourced.internals?.getEnvironment().app?.version).toBe('8.0.0'); - } finally { - vi.unstubAllEnvs(); - } - }); - - it('launch() returns the working public client launchCore() builds', () => { - const client = track(launch('tok', base())); - expect(typeof client.logException).toBe('function'); - expect(typeof client.stop).toBe('function'); - }); - - it('wires the Deno.serve native wrap (patch + restore) and a wrapped request resolves the carrier client', async () => { - type G = { Deno?: { serve: (...a: unknown[]) => unknown } }; - const calls: unknown[][] = []; - const realServe = vi.fn((...args: unknown[]) => { - calls.push(args); - return { shutdown: async () => {}, addr: { port: 0 } }; - }); - (globalThis as G).Deno = { serve: realServe }; - const client = launch('tok', base({ instrumentIncomingRequests: true })); // untracked — stopped below - try { - expect((globalThis as G).Deno?.serve).not.toBe(realServe); // patched - (globalThis as G).Deno?.serve(async () => ({ status: 200 })); // Deno.serve(handler) - const wrapped = calls[0]?.[0] as (req: unknown) => Promise<{ status: number }>; - const res = await wrapped({ method: 'GET', url: '/x', headers: { get: () => null } }); - expect(res).toEqual({ status: 200 }); // wrap ran getClient -> the launched carrier client -> handler - // a throwing handler re-throws through the FULL launch composition (error path, real carrier client) - (globalThis as G).Deno?.serve(async () => { - throw new Error('handler-boom'); - }); - const throwing = calls[1]?.[0] as (req: unknown) => Promise; - await expect( - throwing({ method: 'GET', url: '/boom', headers: { get: () => null } }), - ).rejects.toThrow('handler-boom'); - await client.stop(); - expect((globalThis as G).Deno?.serve).toBe(realServe); // restored on stop - } finally { - await client.stop(); // idempotent — guarantees teardown of the node:http + native patches - delete (globalThis as G).Deno; - } - }); - - it('forwards traceResponse → a wrapped Deno.serve response carries the return headers', async () => { - type G = { Deno?: { serve: (...a: unknown[]) => unknown } }; - const calls: unknown[][] = []; - const realServe = vi.fn((...args: unknown[]) => { - calls.push(args); - return { shutdown: async () => {}, addr: { port: 0 } }; - }); - (globalThis as G).Deno = { serve: realServe }; - const client = launch( - 'tok', - base({ traceResponse: { traceresponse: true, serverTiming: true } }), - ); - // getAttributes is a REQUIRED, non-throwing member of Span (server-instrument.ts's finishWith reads it - // for the F-4 manual-rename check) — omitting it makes finishWith's getAttributes() call throw, which - // is swallowed by finishWith's own try/catch, so setName/setAttribute/finish never run. See the - // matching comment in express/src/middleware.test.ts's fakeTransaction. - const txn = { - getTraceId: () => 'trace-1', - getSpanId: () => 'span-1', - isSampled: () => true, - isFinished: () => false, - setName: vi.fn(), - setAttribute: vi.fn(), - getAttributes: vi.fn(() => ({})), - finish: vi.fn(), - }; - (client as unknown as { registerExt: (n: string, api: unknown) => void }).registerExt( - 'performance', - { startTransaction: () => txn }, - ); - try { - const set: Record = {}; - (globalThis as G).Deno?.serve(async () => ({ - status: 200, - headers: { - set: (n: string, v: string) => { - set[n] = v; - }, - }, - })); - const wrapped = calls[0]?.[0] as (req: unknown) => Promise; - await wrapped({ method: 'GET', url: '/x', headers: { get: () => null } }); - expect(set).toEqual({ - traceresponse: '00-trace-1-span-1-01', - 'Server-Timing': 'traceparent;desc="00-trace-1-span-1-01"', - }); - // Proves finishWith actually ran end to end (not just the pre-finish header write): a - // non-conforming double with no getAttributes() degrades finishWith silently (TypeError swallowed - // by its own try/catch), so finish()/setName() never run. - expect(txn.setName).toHaveBeenCalledWith('GET /x'); - expect(txn.finish).toHaveBeenCalledWith('OK'); - } finally { - await client.stop(); - delete (globalThis as G).Deno; - } - }); - - it('patches Deno.serve BY DEFAULT (no flag)', async () => { - type G = { Deno?: { serve: unknown } }; - const realServe = vi.fn(); - (globalThis as G).Deno = { serve: realServe }; - const client = launch('tok', base()); - try { - expect((globalThis as G).Deno?.serve).not.toBe(realServe); // patched without any flag (default-on) - } finally { - await client.stop(); - expect((globalThis as G).Deno?.serve).toBe(realServe); // restored on stop - delete (globalThis as G).Deno; - } - }); - - it('does NOT patch Deno.serve when instrumentIncomingRequests is false (escape hatch)', async () => { - type G = { Deno?: { serve: unknown } }; - const realServe = vi.fn(); - (globalThis as G).Deno = { serve: realServe }; - const client = launch('tok', base({ instrumentIncomingRequests: false })); - try { - expect((globalThis as G).Deno?.serve).toBe(realServe); // untouched (opted out) - } finally { - await client.stop(); - delete (globalThis as G).Deno; - } - }); -}); - -describe('@bugsee/deno — the event-loop metrics Deno cannot measure', () => { - it('declares that Deno cannot measure event-loop DELAY, so the lag traces are omitted', () => { - // Measured against a real 150ms synchronous block: node 160.956ms, bun 146.634ms, deno 0.065ms. - // Deno's `monitorEventLoopDelay` answers and never throws, so no lower layer can tell — unlike ELU, - // which gives itself away with a zero `idle`. A lag of ~0 is exactly what a healthy process reports, - // which is why fabricating one is worse than reporting nothing. - track(launchCore('tok', base()).client); - expect(createNodeSystemTraceProducers).toHaveBeenCalledTimes(1); - expect(createNodeSystemTraceProducers).toHaveBeenCalledWith( - expect.objectContaining({ measuresEventLoopDelay: false }), - ); - }); - - it.each([ - ['linux', true], - ['darwin', false], - ['win32', false], - ])('measuresConstrainedMemory on %s is %s (the cgroup cap exists only on Linux)', (platform, expected) => { - const real = Object.getOwnPropertyDescriptor(process, 'platform'); - Object.defineProperty(process, 'platform', { value: platform, configurable: true }); - try { - track(launchCore('tok', base()).client); - } finally { - if (real) Object.defineProperty(process, 'platform', real); - } - expect(createNodeSystemTraceProducers).toHaveBeenCalledWith( - expect.objectContaining({ measuresConstrainedMemory: expected }), - ); - }); - - it('builds no default producer set when the caller supplies systemTraceProducers (it would rebind their shared tracker gates)', () => { - vi.mocked(createNodeSystemTraceProducers).mockClear(); - track(launchCore('tok', base({ systemTraceProducers: [] })).client); - expect(createNodeSystemTraceProducers).not.toHaveBeenCalled(); - }); - - it('never reads /proc/meminfo for ram_system_free (a scoped --allow-read would prompt), opts out of gc (blind observer) and keeps the V8 heap (real V8)', () => { - track(launchCore('tok', base()).client); - const arg = vi.mocked(createNodeSystemTraceProducers).mock.calls[0]?.[0]; - expect(arg).not.toHaveProperty('readsProcMeminfo'); // only Bun reads /proc/meminfo - expect(arg?.measuresGc).toBe(false); - expect(arg).not.toHaveProperty('measuresV8Heap'); // the node default (true) applies - }); - - it('injects the node trace producers (not a legacy sampler) and they feed traces.system', async () => { - vi.mocked(createNodeSystemTraceProducers).mockClear(); - const store = memStore(); - track(launchCore('tok', base({ captureStore: store, captureSystemTraces: true })).client); - const produced = vi.mocked(createNodeSystemTraceProducers).mock.results[0]?.value as unknown[]; - expect(Array.isArray(produced)).toBe(true); - expect(produced.length).toBeGreaterThan(0); - for (const p of produced) { - expect(typeof (p as { start: unknown }).start).toBe('function'); - expect(typeof (p as { stop: unknown }).stop).toBe('function'); - } - const traces = (await createCaptureExporter(store).drain()).get('traces.system') ?? []; - const names = traces.map((e) => (e.data as { name: string }).name); - expect(names).toContain('process_memory_rss'); - expect(names).toContain('ram_system_total'); - expect(names).not.toContain('cpu_usage_process'); // no CPU start value: it begins with the first sampled window - // Deno cannot observe a blocked loop, so no lag trace is fabricated. - expect(names.some((n) => n.startsWith('event_loop_lag'))).toBe(false); - }); -}); - -describe('@bugsee/deno — the launch scheduler / onError reach the trace tracker', () => { - const recordingScheduler = () => { - const calls: Array<{ cb: () => void; ms: number }> = []; - const scheduler: Scheduler = { - setInterval: (cb, ms) => { - calls.push({ cb, ms }); - return `h${calls.length}`; - }, - clearInterval: () => {}, - }; - return { calls, scheduler }; - }; - - it('forwards the launch scheduler and onError into the producer factory', () => { - vi.mocked(createNodeSystemTraceProducers).mockClear(); - const { scheduler } = recordingScheduler(); - const onError = vi.fn(); - track(launchCore('tok', base({ scheduler, onError })).client); - expect(createNodeSystemTraceProducers).toHaveBeenCalledTimes(1); - const arg = vi.mocked(createNodeSystemTraceProducers).mock.calls[0]?.[0]; - expect(arg?.scheduler).toBe(scheduler); - expect(arg?.onError).toBe(onError); - }); - - it('sampling runs on the injected scheduler: a fake tick produces a stats emit (no real timer)', async () => { - const { calls, scheduler } = recordingScheduler(); - const store = memStore(); - track( - launchCore('tok', base({ scheduler, captureStore: store, captureSystemTraces: true })).client, - ); - const rss = async () => - ((await createCaptureExporter(store).drain()).get('traces.system') ?? []).filter( - (e) => (e.data as { name: string }).name === 'process_memory_rss', - ).length; - expect(await rss()).toBe(1); // the start baseline - for (const c of calls.filter((x) => x.ms === 1000)) c.cb(); - expect(await rss()).toBe(2); - }); - - it('a throwing reader during a poll reaches options.onError', () => { - const { calls, scheduler } = recordingScheduler(); - const onError = vi.fn(); - track(launchCore('tok', base({ scheduler, onError, captureSystemTraces: true })).client); - const spy = vi.spyOn(process, 'memoryUsage').mockImplementation(() => { - throw new Error('memoryUsage boom'); - }); - try { - for (const c of calls.filter((x) => x.ms === 1000)) c.cb(); - } finally { - spy.mockRestore(); - } - expect(onError.mock.calls.map((c) => (c[0] as Error).message)).toContain('memoryUsage boom'); - }); -}); - -describe('@bugsee/deno — captureSystemTraces:false attaches no trace sampling', () => { - it('no sampling timer, no trace entries; enabling adds exactly the provider tick + the tracker timer', async () => { - const launchWith = (captureSystemTraces: boolean) => { - const calls: number[] = []; - const store = memStore(); - const scheduler: Scheduler = { - setInterval: (_cb, ms) => { - calls.push(ms); - return `h${calls.length}`; - }, - clearInterval: () => {}, - }; - track( - launchCore('tok', base({ scheduler, captureStore: store, captureSystemTraces })).client, - ); - return { store, oneSecond: calls.filter((ms) => ms === 1000).length }; - }; - const off = launchWith(false); - const on = launchWith(true); - expect(on.oneSecond - off.oneSecond).toBe(2); - expect((await createCaptureExporter(off.store).drain()).get('traces.system')).toBeUndefined(); - }); -}); - -describe('@bugsee/deno — the runtime gates reach the shared ProcessTracker', () => { - it('the per-process tracker honours Deno gates end to end: no lag, no gc, no available memory; V8 heap kept', () => { - const calls: Array<() => void> = []; - const scheduler: Scheduler = { - setInterval: (cb) => { - calls.push(cb); - return `h${calls.length}`; - }, - clearInterval: () => {}, - }; - track(launchCore('tok', base({ scheduler, captureSystemTraces: true })).client); - const tracker = processTrackerFor(); // the launch went through the registry accessor: same `process` singleton - expect(tracker.current('v8Heap')?.limit).toBeGreaterThan(0); - const seen: string[] = []; - const off = tracker.onAny((name) => void seen.push(name)); - for (const cb of calls) cb(); - off(); - expect(seen).toContain('memory'); - expect(seen).not.toContain('eventLoop'); - expect(seen).not.toContain('gc'); - }); -}); - -describe('@bugsee/deno — the gc event is never written and arms nothing (blind observer)', () => { - it('captureSystemTraces:false + events on: no gc event after ticks, and no extra sampling timer vs events off', async () => { - const launchWith = (captureSystemEvents: boolean) => { - const callbacks: Array<() => void> = []; - const calls: number[] = []; - const store = memStore(); - const scheduler: Scheduler = { - setInterval: (cb, ms) => { - callbacks.push(cb); - calls.push(ms); - return `h${calls.length}`; - }, - clearInterval: () => {}, - }; - track( - launchCore( - 'tok', - base({ scheduler, captureStore: store, captureSystemTraces: false, captureSystemEvents }), - ).client, - ); - for (const cb of callbacks) cb(); - return { store, oneSecond: calls.filter((ms) => ms === 1000).length }; - }; - const off = launchWith(false); - const on = launchWith(true); - expect(on.oneSecond).toBe(off.oneSecond); // the gated gc stage keeps no tracker timer alive - const names = ((await createCaptureExporter(on.store).drain()).get('events.system') ?? []).map( - (e) => (e.data as { name: string }).name, - ); - expect(names).toContain('process_started'); // not vacuous: events were captured - expect(names).not.toContain('gc'); - }); -}); diff --git a/packages/deno/src/launch.ts b/packages/deno/src/launch.ts deleted file mode 100644 index b160f5bc8..000000000 --- a/packages/deno/src/launch.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { getCarrierClient } from '@bugsee/core'; -import { - type Bugsee, - type BugseeLaunchOptions, - createNodeSystemTraceProducers, - type LaunchResult, - launchCore as nodeLaunchCore, -} from '@bugsee/node'; -import { createDenoServeInterceptor } from './deno-serve-interceptor'; -import { denoSystemProbe } from './environment'; - -// @bugsee/deno launch() — the Deno composition root. Deno 2 runs on a node-compatible API surface (node:http, -// node:fs, node:process, node:worker_threads, node:inspector), so this reuses the ENTIRE @bugsee/node -// composition (transport, fs storage, node:http capture, crash detection, durable queue + capture recovery, -// CPU profiling, ANR/hang detection) and only swaps the two Deno-specific defaults: the system probe (reports -// platform.type 'deno' + the Deno version) and the guarded system trace producers (partial perf_hooks). -// Diagnostics that touch a partially-supported API (node:inspector / worker_threads) are capability-guarded -// in the node tier, so they self-disable where Deno lacks them. Both defaults remain overridable (a -// caller-supplied option spreads AFTER them). - -export function launchCore(appToken: string, options: BugseeLaunchOptions = {}): LaunchResult { - return nodeLaunchCore(appToken, { - systemProbe: denoSystemProbe, - // `measuresEventLoopDelay: false` — Deno's `monitorEventLoopDelay` answers and never throws, but it - // does not observe a blocked loop at all. Measured against a real 150ms synchronous block: node - // 160.956ms, bun 146.634ms, deno 0.065ms. Reporting 0.065ms through a 150ms freeze reads as a - // healthy process, so the lag traces are omitted here rather than fabricated. ELU self-disables on - // its own tell (a zero `idle`), so it needs no flag. - systemTraceProducers: - options.systemTraceProducers ?? - createNodeSystemTraceProducers({ - measuresEventLoopDelay: false, - // `process.constrainedMemory()` is a cgroup cap: measured real on Linux (Bun 1.4.4 / Deno 2.8.3 under `docker -m`), - // while elsewhere there is no cap to report (Deno answers 0), so the trace is gated to Linux. - measuresConstrainedMemory: process.platform === 'linux', - // `ram_system_free` on Deno: `os.freemem()` (MemAvailable on Linux since 2023, avail_phys on Windows) and - // the macOS figure is the async vm_stat read (the SAME definition as Node/Bun/Electron) when the `run` - // permission for /usr/bin/vm_stat is already granted (checked with the never-prompting `permissions.querySync`; - // spawned via `Deno.Command`, so `--allow-run=/usr/bin/vm_stat` suffices), else `Deno.systemMemoryInfo().available` - // (free + inactive pages: a LARGER estimate than the vm_stat definition). It must NOT read /proc/meminfo (no `readsProcMeminfo`): the - // read triggers an interactive permission prompt under a scoped `--allow-read`. - // `PerformanceObserver('gc')` is BLIND on Deno too (0 entries, also with --v8-flags=--expose-gc): omit. - measuresGc: false, - // the shared tracker's sampling timer honors an injected scheduler, and its poll errors are reported - ...(options.scheduler !== undefined ? { scheduler: options.scheduler } : {}), - ...(options.onError !== undefined ? { onError: options.onError } : {}), - }), - ...options, - // LOCAL VARIABLES ARE OFF HERE, and deliberately AFTER `...options` so a caller cannot switch them - // back on. This is not a preference: with `includeCaught` Deno FREEZES. Measured with the real SDK - // on Deno 2.9.6 — the process produced no output at all and never exited, because the SDK's own - // guarded startup paths throw-and-catch internally, so the freeze happens during launch, before any - // application code runs. `Debugger.enable` and `setPauseOnExceptions` both answer "ok"; the pause - // then arrives and `Debugger.paused` never reaches an in-process listener, so nothing ever resumes. - // - // Even on the default (`uncaught`) path Deno never fires a pause, so the feature can only ever cost - // a debugger attachment and return nothing. Same shape as `measuresEventLoopDelay` above: Deno - // answers the call and silently does not do the thing. - captureLocalVariables: false, - // Deno's native serve wrap (instruments idiomatic Deno.serve apps that bypass node:http), CONCATENATED - // before any caller-supplied server instrumentations — never spread-replaced. node still installs its - // own node:http interceptor first when the flag is on; all of it activates only when - // `instrumentIncomingRequests` is set. getClient binds to the carrier. - serverInstrumentations: [ - createDenoServeInterceptor({ - getClient: () => getCarrierClient(options.carrier), - ...(options.traceResponse !== undefined ? { traceResponse: options.traceResponse } : {}), - }), - ...(options.serverInstrumentations ?? []), - ], - }); -} - -/** The public Deno composition root: the launched client. Equivalent to `launchCore(...).client`. */ -export function launch(appToken: string, options: BugseeLaunchOptions = {}): Bugsee { - return launchCore(appToken, options).client; -} diff --git a/packages/deno/src/local-variables-gate.test.ts b/packages/deno/src/local-variables-gate.test.ts deleted file mode 100644 index 9bda9450b..000000000 --- a/packages/deno/src/local-variables-gate.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { launchCore as nodeLaunchCore } from '@bugsee/node'; -import { describe, expect, it, vi } from 'vitest'; -import { launchCore } from './launch'; - -// The gate is asserted against the option this tier hands the node composition, because that is the -// only place the decision exists — the capture itself lives in @bugsee/node. -vi.mock('@bugsee/node', async (importOriginal) => { - const actual = await importOriginal(); - return { ...actual, launchCore: vi.fn(() => ({ client: undefined, internals: undefined })) }; -}); - -const optionsPassed = (over: Record = {}): Record => { - vi.mocked(nodeLaunchCore).mockClear(); - launchCore('tok', over as never); - return vi.mocked(nodeLaunchCore).mock.calls[0]?.[1] as unknown as Record; -}; - -describe('@bugsee/deno — local variables are gated OFF', () => { - it('never enables local-variable capture', () => { - expect(optionsPassed().captureLocalVariables).toBe(false); - }); - - it('cannot be re-enabled by the caller — the gate wins over the option', () => { - // Not a default. A default spreads BEFORE `...options` and a caller would override it; this is - // applied after, because on this runtime the feature does not merely fail, it must not be tried. - expect(optionsPassed({ captureLocalVariables: true }).captureLocalVariables).toBe(false); - expect( - optionsPassed({ captureLocalVariables: { includeCaught: true } }).captureLocalVariables, - ).toBe(false); - }); - - it('leaves every OTHER option alone', () => { - // The gate is surgical: it must not become a place where unrelated options quietly die. - expect(optionsPassed({ appVersion: '9.9.9' }).appVersion).toBe('9.9.9'); - }); -}); diff --git a/packages/deno/src/relaunch.test.ts b/packages/deno/src/relaunch.test.ts deleted file mode 100644 index 2536afa16..000000000 --- a/packages/deno/src/relaunch.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { setCarrierClient, setCarrierLastLaunch } from '@bugsee/core'; -import { afterEach, describe, expect, it, vi } from 'vitest'; - -// `relaunch` must re-run THIS package's launch (Deno system probe + runtime gates), not the one re-exported from the layer below -// The launch is replaced by a spy; the carrier carries the remembered token like a real one. -const { launch } = vi.hoisted(() => ({ launch: vi.fn() })); -vi.mock('./launch', () => ({ launch })); - -import { relaunch } from './relaunch'; - -afterEach(() => launch.mockReset()); - -describe('@bugsee/deno relaunch', () => { - it('rejects while nothing has been launched (there is no token to reuse)', async () => { - await expect(relaunch({ carrier: {} })).rejects.toThrow(/before launch/); - expect(launch).not.toHaveBeenCalled(); - }); - - it('stops the running client, then launches again through this package with the remembered token', async () => { - const carrier = {}; - const order: string[] = []; - const old = { - stop: vi.fn(async () => { - order.push('stop'); - return true; - }), - }; - const next = { stop: vi.fn() }; - launch.mockImplementation(() => { - order.push('launch'); - return next; - }); - setCarrierClient(old, carrier); - setCarrierLastLaunch('tok-1', { carrier }, carrier); - - await expect(relaunch({ carrier, captureNetwork: false })).resolves.toBe(next); - - expect(order).toEqual(['stop', 'launch']); - expect(launch).toHaveBeenCalledTimes(1); - expect(launch).toHaveBeenCalledWith( - 'tok-1', - expect.objectContaining({ carrier, captureNetwork: false }), - ); - }); -}); diff --git a/packages/deno/src/relaunch.ts b/packages/deno/src/relaunch.ts deleted file mode 100644 index c7db2084f..000000000 --- a/packages/deno/src/relaunch.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { relaunchWith } from '@bugsee/core'; -import type { Bugsee, BugseeLaunchOptions } from '@bugsee/node'; -import { launch } from './launch'; - -/** Stop the running client (if any) and launch again with the same token through THIS package's launch, so the - * Deno system probe and the runtime gates are re-applied (the re-exported @bugsee/node `relaunch` would run the - * plain node launch). Bugsee options return to their defaults; integration seams are kept. */ -export const relaunch = (options?: BugseeLaunchOptions): Promise => - relaunchWith(launch, options, options?.carrier); diff --git a/packages/deno/tsconfig.json b/packages/deno/tsconfig.json deleted file mode 100644 index e1e6acac1..000000000 --- a/packages/deno/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "dist", - "rootDir": "src", - "types": ["node"] - }, - "include": ["src", "test"] -} diff --git a/packages/deno/tsup.config.ts b/packages/deno/tsup.config.ts deleted file mode 100644 index 82e2f36b8..000000000 --- a/packages/deno/tsup.config.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { defineConfig } from 'tsup'; -import { baseConfig } from '../../tsup.config.base'; - -export default defineConfig(baseConfig); diff --git a/packages/deno/vitest.config.ts b/packages/deno/vitest.config.ts deleted file mode 100644 index 9f2415463..000000000 --- a/packages/deno/vitest.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { defineConfig } from 'vitest/config'; - -// Coverage gate: 100% line/functions/statements, >=90% branch. -export default defineConfig({ - test: { - // The runner is far slower than a dev machine — roughly 7-18x under coverage instrumentation — and - // this repo has legitimately heavy suites (IndexedDB queues, property tests, CPU profiling, linearity - // guards). vitest's 5 s default is calibrated for fast unit tests, so on CI it converted machine load - // into red builds: three different packages timed out on three consecutive runs, none of them for a - // reason related to the code under test. The e2e packages already set their own timeouts for exactly - // this reason; this extends the same convention to the rest. - testTimeout: 30_000, - environment: 'node', - include: ['src/**/*.test.ts'], - coverage: { - provider: 'v8', - include: ['src/**/*.ts'], - exclude: ['src/**/*.test.ts', 'src/**/*.test-d.ts', 'src/**/*.d.ts'], - thresholds: { - lines: 100, - functions: 100, - statements: 100, - branches: 90, - }, - }, - }, -}); diff --git a/packages/e2e-kit/src/collector.ts b/packages/e2e-kit/src/collector.ts index ef64a66bf..17f8e135c 100644 --- a/packages/e2e-kit/src/collector.ts +++ b/packages/e2e-kit/src/collector.ts @@ -2,7 +2,7 @@ // It implements just enough of the control plane (session → issue → signed PUT) for the SDK's upload // pipeline to deliver a bundle, plus an /echo endpoint the app fetches so the network interceptor has a // real outgoing request to capture. Runs IN the test (runner) process; the app runs in a separate -// node/bun/deno process and reaches it over loopback HTTP — so the captured uploads ARE the assertion +// node/bun process and reaches it over loopback HTTP — so the captured uploads ARE the assertion // channel (no IPC needed). import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http'; import type { AddressInfo } from 'node:net'; diff --git a/packages/elysia/README.md b/packages/elysia/README.md index 876d4e835..8c431bd81 100644 --- a/packages/elysia/README.md +++ b/packages/elysia/README.md @@ -1,6 +1,6 @@ # @bugsee/elysia -Elysia adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for Elysia apps on Bun, Node.js and Deno. +Elysia adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for Elysia apps on Bun and Node.js. Part of the Bugsee JavaScript SDK (public beta, 0.1.0-beta.x). diff --git a/packages/elysia/src/index.ts b/packages/elysia/src/index.ts index c0d60e0e3..00e35593e 100644 --- a/packages/elysia/src/index.ts +++ b/packages/elysia/src/index.ts @@ -1,6 +1,6 @@ // @bugsee/elysia — Elysia plugin adapter. // Hook-based setup over the per-request context foundation. elysia is a PEER (structural types only). -// Works on node/bun/deno-hosted Elysia (wherever the launched @bugsee/node client provides the context store). +// Works on node/bun-hosted Elysia (wherever the launched @bugsee/node client provides the context store). // Single-install re-export: surface the full public SDK (launch, Bugsee, options + manual-API // types) so users install only `@bugsee/elysia` and import everything from one place. diff --git a/packages/express/README.md b/packages/express/README.md index bc78985e7..be7e76caf 100644 --- a/packages/express/README.md +++ b/packages/express/README.md @@ -1,6 +1,6 @@ # @bugsee/express -Express adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for Express apps on Node.js, Bun and Deno. +Express adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for Express apps on Node.js and Bun. Part of the Bugsee JavaScript SDK (public beta, 0.1.0-beta.x). diff --git a/packages/fastify/README.md b/packages/fastify/README.md index e5cb801c9..a04ffdd35 100644 --- a/packages/fastify/README.md +++ b/packages/fastify/README.md @@ -1,6 +1,6 @@ # @bugsee/fastify -Fastify adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for Fastify apps on Node.js, Bun and Deno. +Fastify adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for Fastify apps on Node.js and Bun. Part of the Bugsee JavaScript SDK (public beta, 0.1.0-beta.x). diff --git a/packages/hapi/README.md b/packages/hapi/README.md index 1dc765e66..b43bc114d 100644 --- a/packages/hapi/README.md +++ b/packages/hapi/README.md @@ -1,6 +1,6 @@ # @bugsee/hapi -hapi adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for @hapi/hapi servers on Node.js, Bun and Deno. +hapi adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for @hapi/hapi servers on Node.js and Bun. Part of the Bugsee JavaScript SDK (public beta, 0.1.0-beta.x). diff --git a/packages/hapi/src/index.ts b/packages/hapi/src/index.ts index 3cc680f2d..c34c78f02 100644 --- a/packages/hapi/src/index.ts +++ b/packages/hapi/src/index.ts @@ -1,6 +1,6 @@ // @bugsee/hapi — Hapi adapter. // Lifecycle-extension setup over the per-request context foundation. @hapi/hapi is a PEER (structural -// types only). Works on node/bun/deno-hosted Hapi (wherever the launched @bugsee/node client provides the +// types only). Works on node/bun-hosted Hapi (wherever the launched @bugsee/node client provides the // context store). // Single-install re-export: surface the full public SDK (launch, Bugsee, options + manual-API diff --git a/packages/hono/README.md b/packages/hono/README.md index e178a4611..42d478544 100644 --- a/packages/hono/README.md +++ b/packages/hono/README.md @@ -1,6 +1,6 @@ # @bugsee/hono -Hono adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for Hono apps hosted on Node.js, Bun or Deno. +Hono adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for Hono apps hosted on Node.js or Bun. Part of the Bugsee JavaScript SDK (public beta, 0.1.0-beta.x). diff --git a/packages/hono/src/index.ts b/packages/hono/src/index.ts index 354a60ce5..c6660f6de 100644 --- a/packages/hono/src/index.ts +++ b/packages/hono/src/index.ts @@ -1,6 +1,6 @@ // @bugsee/hono — Hono middleware adapter. // A single middleware over the per-request context foundation. hono is a PEER (structural types only). -// Works on node/bun/deno-hosted Hono (wherever the launched @bugsee/node client provides the context store). +// Works on node/bun-hosted Hono (wherever the launched @bugsee/node client provides the context store). // Single-install re-export: surface the full public SDK (launch, Bugsee, options + manual-API // types) so users install only `@bugsee/hono` and import everything from one place. diff --git a/packages/hono/src/middleware.ts b/packages/hono/src/middleware.ts index 718b3beb4..cc17a7251 100644 --- a/packages/hono/src/middleware.ts +++ b/packages/hono/src/middleware.ts @@ -12,7 +12,7 @@ import { randomId } from '@bugsee/util'; // around next()). NOTE: Hono only routes `instanceof Error` throws to `c.error`; a non-Error throw is // invisible here (Hono drops it the same way) — we stay transparent rather than wrap next(). // - finishes the transaction (route-parametrized name + status; `c.res.status` is final by here). -// Fully defensive: never throws into the request; works across node/bun/deno wherever the launched client +// Fully defensive: never throws into the request; works across node/bun wherever the launched client // provides the context store. /** Minimal structural Hono request. */ diff --git a/packages/instrumentation-tests/README.md b/packages/instrumentation-tests/README.md index cdb6f950f..98c5d01cc 100644 --- a/packages/instrumentation-tests/README.md +++ b/packages/instrumentation-tests/README.md @@ -1,7 +1,7 @@ # @bugsee/instrumentation-tests Cross-runtime **end-to-end instrumentation harness**. It boots the *real* SDK in a *real* separate -`node` / `bun` / `deno` process — no fakes, real timers, a real outgoing `fetch`, the real V8 CPU +`node` / `bun` process — no fakes, real timers, a real outgoing `fetch`, the real V8 CPU profiler, the real worker-thread hang watchdog — pointed at a local **mock collector**, and asserts the actual uploaded bundle. This is the layer the in-process unit tests (which run under Node with injected fakes) cannot reach: it proves the *assembled* SDK runs and produces the right wire output on each @@ -14,7 +14,7 @@ pnpm --filter @bugsee/instrumentation-tests test:e2e The `*.e2e.ts` suites are **not** part of `pnpm test` (the root globs `*.test.ts`) and have no coverage gate — they spawn real processes. Since 2026-07-27 they **do run in CI**, in their own `e2e` job with -`bun` and `deno` installed (`.github/workflows/ci.yml`). Before that they were outside the gate +`bun` installed (`.github/workflows/ci.yml`). Before that they were outside the gate entirely, which the adversarial review identified as the reason most of its ~90 findings survived ~100% unit coverage. @@ -25,18 +25,17 @@ the `check` job. They ran in NO CI job until 2026-07-28: this package had no `te ## What runs -One scenario module (`app/scenario.ts`) drives the SDK's public surface; three thin entries inject each -runtime's own launch (`@bugsee/node` / `@bugsee/bun` / `@bugsee/deno`). The runner (`test/`) starts the +One scenario module (`app/scenario.ts`) drives the SDK's public surface; two thin entries inject each +runtime's own launch (`@bugsee/node` / `@bugsee/bun`). The runner (`test/`) starts the mock collector, spawns each entry as a child process, and asserts the captured uploads. | Runtime | Launched via | Resolves the workspace TS source by | | --- | --- | --- | | node | `tsx` (a devDep — the guaranteed target) | tsx's TS loader | | bun | `bun` (native TS) | bun's node_modules resolution | -| deno | `deno run -A --node-modules-dir=manual --sloppy-imports` | pnpm's node_modules + sloppy (extensionless) imports | -A runtime whose binary is absent is logged and skipped (so CI without bun/deno still runs the node -suite). bun/deno are probed on `PATH` and at `~/.bun/bin` / `~/.deno/bin`. +A runtime whose binary is absent is logged and skipped (so CI without bun still runs the node +suite). bun is probed on `PATH` and at `~/.bun/bin`. ### Scenarios asserted per runtime - **main** (exits 0): console logs → `logs.json`; a captured outgoing `/echo` → `network.json`; a diff --git a/packages/instrumentation-tests/app/browser-scenario.ts b/packages/instrumentation-tests/app/browser-scenario.ts index 26e40c8cb..ecdeace80 100644 --- a/packages/instrumentation-tests/app/browser-scenario.ts +++ b/packages/instrumentation-tests/app/browser-scenario.ts @@ -1,5 +1,5 @@ // The battery the browser harness runs inside a REAL Chromium page (`test/browser.e2e.ts` bundles this -// file with esbuild and serves it). The node/bun/deno entries spawn a real process; this is the same idea +// file with esbuild and serves it). The node/bun entries spawn a real process; this is the same idea // for the web tier — the real `@bugsee/browser` launch, a real DOM, a real rrweb recorder, real // `window.onerror`, real `fetch`, and (in the `persist` scenario) real IndexedDB. // diff --git a/packages/instrumentation-tests/app/entry-deno.ts b/packages/instrumentation-tests/app/entry-deno.ts deleted file mode 100644 index 714390f5c..000000000 --- a/packages/instrumentation-tests/app/entry-deno.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Deno entry: the real @bugsee/deno SDK under a real `deno` process (native TS, node-compat). -import { launch } from '@bugsee/deno'; -import { runEntry } from './run-entry'; - -runEntry(launch); diff --git a/packages/instrumentation-tests/app/entry-umbrella.ts b/packages/instrumentation-tests/app/entry-umbrella.ts index 2d5e85513..6169fa1ee 100644 --- a/packages/instrumentation-tests/app/entry-umbrella.ts +++ b/packages/instrumentation-tests/app/entry-umbrella.ts @@ -1,12 +1,11 @@ // WAVE 3b.1 — the entry that installs the way CUSTOMERS do. // -// Every other entry imports its runtime's platform package directly (`@bugsee/node`, `@bugsee/bun`, -// `@bugsee/deno`). No customer does that: the documented single-install path is `@bugsee/bugsee`, and which +// Every other entry imports its runtime's platform package directly (`@bugsee/node`, `@bugsee/bun`). No customer does that: the documented single-install path is `@bugsee/bugsee`, and which // implementation they get is decided by the umbrella's `exports` conditions on their runtime. Nothing in // the suite exercised that decision, which is why a runtime resolving to the wrong implementation was // invisible to every one of the 109 e2e tests. // -// This file is deliberately identical for node, bun and deno — the ONLY thing that varies is which runtime +// This file is deliberately identical for node and bun — the ONLY thing that varies is which runtime // loads it, and therefore which condition the umbrella resolves through. That is the whole subject. import { launch } from '@bugsee/bugsee'; import { runEntry } from './run-entry'; diff --git a/packages/instrumentation-tests/app/scenario.ts b/packages/instrumentation-tests/app/scenario.ts index 018e9f7ab..21fc293ee 100644 --- a/packages/instrumentation-tests/app/scenario.ts +++ b/packages/instrumentation-tests/app/scenario.ts @@ -1,5 +1,5 @@ // The instrumentation battery the app runs under each real runtime. One scenario module, three runtime -// entries (entry-node/bun/deno) inject their own runtime's launch(). Everything here is plain portable +// entries (entry-node/bun) inject their own runtime's launch(). Everything here is plain portable // JS the SDK's public surface drives — no fakes, no injected seams: a real process, real timers, a real // outgoing fetch, real console output, the real V8 CPU profiler, and the real worker-thread hang // watchdog. The only "mock" is the upload destination (the collector), exactly as a customer's backend @@ -189,7 +189,7 @@ async function runCrashScenario(launch: LaunchFn, collectorUrl: string): Promise /** * Incoming-server battery: launch with the default-on `instrumentIncomingRequests`, stand up a REAL - * `node:http` server (works on node/bun/deno via their node:http compat — the slice-4 spikes proved the + * `node:http` server (works on node/bun via their node:http compat — the slice-4 spikes proved the * emit patch fires on all three), hit it once with a real request, and report FROM the handler. The proof: * the node:http emit patch opens a per-request context for the in-flight request, so (a) the handler's log * line and (b) the handler-raised error report both carry the SAME request `context_id`. (The `http.server` @@ -321,7 +321,7 @@ async function runDiskRecoveryScenario(launch: LaunchFn, collectorUrl: string): * producing); the error report then drains the capture window, which reads the OFF-THREAD-written chunks * back off disk — so the delivered bundle's logs.json + network.json are the end-to-end proof that the * off-thread path produces correct bundles on the runtime. (If a runtime lacked worker_threads the writer - * would degrade to the on-thread drainer and still be correct — but node/bun/deno all have it.) Exits 0. + * would degrade to the on-thread drainer and still be correct — but node/bun both have it.) Exits 0. */ async function runWorkerWriterScenario(launch: LaunchFn, collectorUrl: string): Promise { const dataDir = process.env.BUGSEE_E2E_DATADIR ?? ''; @@ -526,11 +526,11 @@ async function runRejectScenario(launch: LaunchFn, collectorUrl: string): Promis } /** - * The NATIVE server path — `Bun.serve` / `Deno.serve`. + * The NATIVE server path — `Bun.serve`. * * Every other server scenario goes through `node:http.createServer`, which is exactly the path idiomatic - * Bun and Deno apps do NOT take: `Bun.serve({fetch})` and `Deno.serve()` bypass node:http entirely, which - * is why `@bugsee/bun` and `@bugsee/deno` ship interceptors for them. Nothing in the suite exercised those + * Bun apps do NOT take: `Bun.serve({fetch})` bypasses node:http entirely, which + * is why `@bugsee/bun` ships an interceptor for it. Nothing in the suite exercised those * interceptors, so an umbrella that resolved to `@bugsee/node` — losing them completely — was invisible. * * On node there is no native serve to instrument, so the scenario reports that and exits cleanly rather @@ -539,9 +539,6 @@ async function runRejectScenario(launch: LaunchFn, collectorUrl: string): Promis async function runNativeServerScenario(launch: LaunchFn, collectorUrl: string): Promise { const g = globalThis as { Bun?: { serve(o: unknown): { port: number; stop(): void } }; - Deno?: { - serve(o: unknown, h?: unknown): { addr: { port: number }; shutdown(): Promise }; - }; }; const client = await launch('e2e-app-token', { endpoint: collectorUrl, @@ -565,10 +562,6 @@ async function runNativeServerScenario(launch: LaunchFn, collectorUrl: string): const server = g.Bun.serve({ port: 0, fetch: handler }); port = server.port; stop = () => server.stop(); - } else if (g.Deno !== undefined) { - const server = g.Deno.serve({ port: 0, onListen: () => {} }, handler); - port = server.addr.port; - stop = () => server.shutdown(); } else { console.log('[e2e] no native serve on this runtime — nothing to instrument'); await client.flush(20_000); diff --git a/packages/instrumentation-tests/package.json b/packages/instrumentation-tests/package.json index 82a7ef81a..3663fd6bf 100644 --- a/packages/instrumentation-tests/package.json +++ b/packages/instrumentation-tests/package.json @@ -2,7 +2,7 @@ "name": "@bugsee/instrumentation-tests", "version": "0.1.0", "private": true, - "description": "Cross-runtime end-to-end instrumentation harness: boots the real SDK under node/bun/deno against a mock collector and asserts the uploaded bundle.", + "description": "Cross-runtime end-to-end instrumentation harness: boots the real SDK under node/bun against a mock collector and asserts the uploaded bundle.", "license": "MIT", "type": "module", "scripts": { @@ -19,7 +19,6 @@ "@bugsee/bundler-plugin-core": "workspace:*", "@bugsee/cloudflare": "workspace:*", "@bugsee/core": "workspace:*", - "@bugsee/deno": "workspace:*", "@bugsee/e2e-kit": "workspace:*", "@bugsee/node": "workspace:*", "@bugsee/opentelemetry": "workspace:*", diff --git a/packages/instrumentation-tests/test/durable-object-tenants.e2e.ts b/packages/instrumentation-tests/test/durable-object-tenants.e2e.ts index 7bd7e11b9..3e42e989d 100644 --- a/packages/instrumentation-tests/test/durable-object-tenants.e2e.ts +++ b/packages/instrumentation-tests/test/durable-object-tenants.e2e.ts @@ -108,7 +108,7 @@ describe('Durable Object tenant isolation (real workerd via miniflare)', () => { it('the edge upload path emits nothing that violates the upload contract', () => { // The collector schema-validates every session/issue/manifest/request.json and RECORDS failures. That - // recording is inert unless a suite reads it — and until now only the node/bun/deno suite did, so a + // recording is inert unless a suite reads it — and until now only the node/bun suite did, so a // wire break on the EDGE assembler (a different assembler, and the one this session built) would have // been recorded and silently discarded. assertNoContractViolations(collector); diff --git a/packages/instrumentation-tests/test/edge.e2e.ts b/packages/instrumentation-tests/test/edge.e2e.ts index 618dee750..1e194b324 100644 --- a/packages/instrumentation-tests/test/edge.e2e.ts +++ b/packages/instrumentation-tests/test/edge.e2e.ts @@ -107,7 +107,7 @@ describe('real-edge VM smoke (@edge-runtime/vm, a WinterCG isolate)', () => { // Runs last, so it covers every upload the three smokes above produced. The collector schema-validates // each session/issue/manifest/request.json and RECORDS failures; that recording is inert unless a suite - // reads it, and until now only the node/bun/deno suite did. A wire break on the EDGE assembler — a + // reads it, and until now only the node/bun suite did. A wire break on the EDGE assembler — a // different assembler from the node one — would have been recorded and silently discarded. it('none of the edge upload paths violate the upload contract', () => { assertNoContractViolations(collector); diff --git a/packages/instrumentation-tests/test/instrumentation.e2e.ts b/packages/instrumentation-tests/test/instrumentation.e2e.ts index 5a9ff3eee..e88f77a4b 100644 --- a/packages/instrumentation-tests/test/instrumentation.e2e.ts +++ b/packages/instrumentation-tests/test/instrumentation.e2e.ts @@ -1,6 +1,6 @@ // Cross-runtime end-to-end instrumentation harness. // -// For each available runtime (node via tsx, bun, deno) this boots the REAL SDK in a REAL separate +// For each available runtime (node via tsx, bun) this boots the REAL SDK in a REAL separate // process — no fakes, real timers, the real V8 CPU profiler, the real worker-thread hang watchdog, a // real outgoing fetch — pointed at a local mock collector, and asserts the actual uploaded bundle: // • one session carrying the runtime's platform identity, @@ -82,7 +82,7 @@ if (targets.find((t) => t.name === 'node')?.bin === undefined) { ); } -// bun/deno run only where installed. +// bun runs only where installed. describe.each( targets.filter((t): t is RuntimeTarget & { bin: string } => t.bin !== undefined), )('instrumentation e2e — $name', (target) => { @@ -142,7 +142,7 @@ describe.each( app: { uptime_s?: number }; }; // C14: process uptime at session start is a whole-second snapshot in environment.app (replaces the - // retired per-second `process_uptime_s` trace); process.uptime() answers on real node, bun and deno. + // retired per-second `process_uptime_s` trace); process.uptime() answers on real node and bun. expect(Number.isInteger(env.app.uptime_s)).toBe(true); expect(env.app.uptime_s).toBeGreaterThanOrEqual(0); expect(env.runtime.type).toBe(target.name); @@ -152,14 +152,6 @@ describe.each( expect(env.platform.type).not.toBe(target.name); expect(['macos', 'linux', 'windows']).toContain(env.platform.type); expect(env.platform.version.length).toBeGreaterThan(0); - if (target.name === 'deno') { - // Proves the e2e reads the REAL Deno version (Deno.version.deno → a small major) and NOT the - // node-compat process.versions.node (major ≥ 18) — the milestone's headline gotcha, verified - // end-to-end on the real Deno runtime (the unit tests run under node and cannot reach this). - const major = Number(env.runtime.version.split('.')[0]); - expect(major).toBeGreaterThanOrEqual(1); - expect(major).toBeLessThan(18); - } }); it('captured the real outgoing /echo request', () => { diff --git a/packages/instrumentation-tests/test/local-variables.e2e.ts b/packages/instrumentation-tests/test/local-variables.e2e.ts index 7133907e8..5b945ea1e 100644 --- a/packages/instrumentation-tests/test/local-variables.e2e.ts +++ b/packages/instrumentation-tests/test/local-variables.e2e.ts @@ -64,7 +64,7 @@ describe.each(targets)('local variables + source context — $name', (target) => }); it('degrades CLEANLY where the runtime cannot pause — no half-captured frames', () => { - // Bun and Deno reuse this composition verbatim and their debugger support is not Node's: Bun's + // Bun reuses this composition verbatim and its debugger support is not Node's: Bun's // `session.connect()` succeeds and then `Debugger.enable` throws. What must hold everywhere is that // the crash is still reported and the frames are either fully captured or not captured at all — // never partially, which would be a report that looks enriched and is not. diff --git a/packages/instrumentation-tests/test/opentelemetry.e2e.ts b/packages/instrumentation-tests/test/opentelemetry.e2e.ts index 0239b89d9..9eb0fadc4 100644 --- a/packages/instrumentation-tests/test/opentelemetry.e2e.ts +++ b/packages/instrumentation-tests/test/opentelemetry.e2e.ts @@ -9,7 +9,7 @@ // one. Every APM batch in every previous e2e 404'd into `onError`, unseen. // // Node only, deliberately. The subject here is the OTel wiring, which is runtime-independent; running the -// same battery under bun and deno would re-test their `@opentelemetry/*` module resolution rather than +// same battery under bun would re-test its `@opentelemetry/*` module resolution rather than // anything about the bridge. The runtime matrix is covered by `instrumentation.e2e.ts`. import { spawn } from 'node:child_process'; import { fileURLToPath } from 'node:url'; diff --git a/packages/instrumentation-tests/test/runtimes.ts b/packages/instrumentation-tests/test/runtimes.ts index a232fc64f..461486f1f 100644 --- a/packages/instrumentation-tests/test/runtimes.ts +++ b/packages/instrumentation-tests/test/runtimes.ts @@ -2,8 +2,6 @@ // through a different real runtime binary, importing that runtime's own SDK package: // node → tsx (TS loader) + entry-node (@bugsee/node) // bun → bun (native TS) + entry-bun (@bugsee/bun) -// deno → deno (native TS) + entry-deno (@bugsee/deno); needs --node-modules-dir=manual to use pnpm's -// node_modules and --sloppy-imports for our extensionless relative imports. // A runtime whose binary is absent is reported unavailable so the runner can skip (and log) it rather // than fail — node (via the always-present tsx devDep) is the one guaranteed target. import { execFileSync, spawn } from 'node:child_process'; @@ -12,7 +10,7 @@ import { join } from 'node:path'; import process from 'node:process'; import { fileURLToPath } from 'node:url'; -export type RuntimeName = 'node' | 'bun' | 'deno'; +export type RuntimeName = 'node' | 'bun'; export interface RuntimeTarget { name: RuntimeName; @@ -66,7 +64,7 @@ export function resolveTsx(): string | undefined { ]); } -/** All three targets, with availability resolved. */ +/** Both targets, with availability resolved. */ export function runtimeTargets(): RuntimeTarget[] { return [ { @@ -83,20 +81,13 @@ export function runtimeTargets(): RuntimeTarget[] { entry: entryPath('entry-bun.ts'), umbrellaEntry: entryPath('entry-umbrella.ts'), }, - { - name: 'deno', - bin: resolveBin(['deno', join(homedir(), '.deno', 'bin', 'deno')]), - baseArgs: ['run', '-A', '--node-modules-dir=manual', '--sloppy-imports'], - entry: entryPath('entry-deno.ts'), - umbrellaEntry: entryPath('entry-umbrella.ts'), - }, ]; } /** * The runtime's OWN version, read from its binary. * - * Needed because Bun and Deno both expose a `process.versions.node` for compatibility, so "not the node + * Needed because Bun exposes a `process.versions.node` for compatibility, so "not the node * version" is not a usable assertion — comparing against the HARNESS's node version passes by accident * whenever the compat version merely differs from it. This gives the exact value to expect. */ @@ -106,7 +97,7 @@ export function runtimeOwnVersion(target: RuntimeTarget): string { } const bin = target.bin as string; const out = execFileSync(bin, ['--version'], { encoding: 'utf8' }); - // bun prints `1.3.14`; deno prints `deno 2.8.3 (stable, …)` across several lines. + // bun prints `1.3.14`. const first = out.split('\n')[0] ?? ''; return (/(\d+\.\d+\.\d+[^\s(]*)/.exec(first)?.[1] ?? first).trim(); } diff --git a/packages/instrumentation-tests/test/tsup-node-protocol.e2e.ts b/packages/instrumentation-tests/test/tsup-node-protocol.e2e.ts index 1b0b4950f..703ab24dc 100644 --- a/packages/instrumentation-tests/test/tsup-node-protocol.e2e.ts +++ b/packages/instrumentation-tests/test/tsup-node-protocol.e2e.ts @@ -13,11 +13,11 @@ // any package's own checked-in `dist/`. // // COVERAGE: the original guard checked exactly one specifier (`node:async_hooks`) in exactly one -// package (`@bugsee/cloudflare`) — narrow enough that a regression confined to, say, `@bugsee/deno`'s +// package (`@bugsee/cloudflare`) — narrow enough that a regression confined to, say, `@bugsee/bun`'s // `node:process` import would sail through green. This is table-driven across EVERY package verified // to import a `node:`-prefixed builtin — statically OR dynamically — from its own (non-test, // non-string-embedded) source AND built via tsup + `baseConfig` (i.e. published, not a dev-only/no-build -// package): `@bugsee/cloudflare`, `@bugsee/node`, `@bugsee/node-utils`, `@bugsee/bun`, `@bugsee/deno`, +// package): `@bugsee/cloudflare`, `@bugsee/node`, `@bugsee/node-utils`, `@bugsee/bun`, // `@bugsee/electron`, `@bugsee/bundler-plugin-core`, `@bugsee/nestjs`, `@bugsee/remix`. // // The population was derived by scanning every `packages/*/src` tree (excluding `.test.`/`.fuzz.`/ @@ -127,11 +127,6 @@ const targets: readonly NodeProtocolTarget[] = [ pkgDir: 'packages/bun', specifiers: ['node:process'], }, - { - label: '@bugsee/deno', - pkgDir: 'packages/deno', - specifiers: ['node:process'], - }, { // src/native-crash-source.ts imports node:fs + node:path, reachable only via src/main.ts (the // Node-process entry) — main-imports-it -> launch-main.ts imports it -> main.ts imports launch-main. diff --git a/packages/instrumentation-tests/test/umbrella-conditions.e2e.ts b/packages/instrumentation-tests/test/umbrella-conditions.e2e.ts index 0c7000df3..cf4d28b00 100644 --- a/packages/instrumentation-tests/test/umbrella-conditions.e2e.ts +++ b/packages/instrumentation-tests/test/umbrella-conditions.e2e.ts @@ -2,7 +2,7 @@ // // The umbrella had three conditions (browser / node / default). Every runtime that set none of them fell // through to `default`, i.e. the BROWSER entry — IndexedDB, DOM, a page lifecycle — none of which exists on -// workerd, Vercel Edge, or in a Web Worker. Bun and Deno were worse than that: they set `node`, so they +// workerd, Vercel Edge, or in a Web Worker. Bun was worse than that: it sets `node`, so it // resolved the Node SDK and silently lost their own composition (measured through the real runtimes: Bun 1.3.14 reporting as `node` 24.3.0, and `Bun.serve` left uninstrumented entirely). // // The lesson from that is why this file exists: an `exports` entry is only as good as the resolution that @@ -12,7 +12,7 @@ // // ORDER is the substance of the contract: every one of these runtimes sets SEVERAL conditions, and // resolution takes the FIRST match in the map. `workerd` sets `worker` and `browser` too; `edge-light` the -// same; Bun sets `node`; Deno sets `node`. Get the order wrong and the map still "has" the condition while +// same; Bun sets `node`. Get the order wrong and the map still "has" the condition while // resolving to something else entirely — which is precisely the failure this suite exists to catch. import { build } from 'esbuild'; import { describe, expect, it } from 'vitest'; @@ -97,7 +97,6 @@ describe('the umbrella resolves the right entry per runtime', () => { }, { runtime: 'a Web Worker build', conditions: ['worker', 'browser'], entry: 'index.worker.ts' }, { runtime: 'Bun', conditions: ['bun', 'node'], entry: 'index.bun.ts' }, - { runtime: 'Deno', conditions: ['deno', 'node'], entry: 'index.deno.ts' }, // The two canaries: without them, "the specific runtimes win" is satisfied by a map that never // resolves the general ones at all. { runtime: 'plain node', conditions: ['node'], entry: 'index.node.ts' }, @@ -112,7 +111,7 @@ describe('the umbrella resolves the right entry per runtime', () => { it('every declared condition resolves to a DISTINCT entry', () => { // A duplicate would mean a condition silently aliases another runtime's composition — the exact shape - // of the original defect, where bun and deno both resolved the node entry. + // of the original defect, where bun resolved the node entry. const entries = CASES.map((c) => c.entry); expect(new Set(entries).size).toBe(entries.length); }); diff --git a/packages/instrumentation-tests/test/umbrella.e2e.ts b/packages/instrumentation-tests/test/umbrella.e2e.ts index 6241d441a..bdcb87ec7 100644 --- a/packages/instrumentation-tests/test/umbrella.e2e.ts +++ b/packages/instrumentation-tests/test/umbrella.e2e.ts @@ -1,7 +1,6 @@ // WAVE 3b.1 — the SDK installed the way customers install it. // -// Every other e2e entry imports its runtime's platform package directly (`@bugsee/node`, `@bugsee/bun`, -// `@bugsee/deno`). No customer does that. The documented single-install path is `@bugsee/bugsee`, and which +// Every other e2e entry imports its runtime's platform package directly (`@bugsee/node`, `@bugsee/bun`). No customer does that. The documented single-install path is `@bugsee/bugsee`, and which // implementation they get is decided by the umbrella's `exports` conditions ON THEIR RUNTIME. Nothing in // the suite exercised that decision — which is precisely why a runtime resolving to the wrong // implementation stayed invisible to all 109 e2e tests. @@ -87,8 +86,8 @@ describe('the umbrella install path', () => { }); it('reports the runtime’s OWN version', async () => { - // Asserted against the value the BINARY reports, not merely "different from node's". Bun and Deno - // each expose a `process.versions.node` for compatibility, so a not-equal check passes by accident + // Asserted against the value the BINARY reports, not merely "different from node's". Bun + // exposes a `process.versions.node` for compatibility, so a not-equal check passes by accident // whenever that compat version happens to differ from the harness's own node — which is exactly how // my first version of this test passed on Bun while the defect was present. const bundles = await runUmbrella(target); @@ -110,9 +109,9 @@ describe('the umbrella install path', () => { // WAVE 3b.1/3b.5 — the native server path, through the umbrella. // // The identity assertions above prove the umbrella resolves the right PACKAGE. This proves the thing that -// actually costs a customer data when it does not: `Bun.serve({fetch})` and `Deno.serve()` bypass node:http -// entirely, which is why @bugsee/bun and @bugsee/deno ship interceptors for them — and why an umbrella that -// resolved to @bugsee/node left idiomatic Bun and Deno servers completely uninstrumented. +// actually costs a customer data when it does not: `Bun.serve({fetch})` bypasses node:http +// entirely, which is why @bugsee/bun ships an interceptor for it — and why an umbrella that +// resolved to @bugsee/node left idiomatic Bun servers completely uninstrumented. // // Nothing in the suite exercised those interceptors on any entry, so this is the first coverage they have. describe('the umbrella instruments the NATIVE server', () => { @@ -126,7 +125,7 @@ describe('the umbrella instruments the NATIVE server', () => { }); for (const target of available.filter((t) => t.name !== 'node')) { - it(`${target.name}: a request to ${target.name === 'bun' ? 'Bun.serve' : 'Deno.serve'} is captured`, async () => { + it(`${target.name}: a request to Bun.serve is captured`, async () => { collector.uploads.length = 0; const result = await runScenarioProcess( target, diff --git a/packages/instrumentation-tests/vitest.config.ts b/packages/instrumentation-tests/vitest.config.ts index 48680a0f1..81807a966 100644 --- a/packages/instrumentation-tests/vitest.config.ts +++ b/packages/instrumentation-tests/vitest.config.ts @@ -1,7 +1,7 @@ import { defineConfig } from 'vitest/config'; // The cross-runtime e2e harness. Unlike the unit packages this is NOT a coverage-gated suite: it spawns -// real node/bun/deno processes and asserts their uploaded bundles, so it is intentionally excluded from +// real node/bun processes and asserts their uploaded bundles, so it is intentionally excluded from // the default `pnpm test` (the root config globs *.test.ts; these are *.e2e.ts) and run on demand via // `pnpm test:e2e`. Generous timeouts cover process spin-up + the deliberate hang/profile windows; the // per-runtime suites spawn their processes sequentially (one beforeAll at a time), so the spawned diff --git a/packages/integration-shims/src/index.test.ts b/packages/integration-shims/src/index.test.ts index a499a2fb9..cb3c46417 100644 --- a/packages/integration-shims/src/index.test.ts +++ b/packages/integration-shims/src/index.test.ts @@ -59,9 +59,9 @@ describe('createNoopCaptureProvider', () => { }); expect(p.name).toBe('X'); expect(p.controllingOption).toBe('com.bugsee.option.capture.x'); - expect( - createNoopCaptureProvider({ name: 'Y', runtime: 'deno', logger }).controllingOption, - ).toBe(undefined); + expect(createNoopCaptureProvider({ name: 'Y', runtime: 'bun', logger }).controllingOption).toBe( + undefined, + ); }); it('warns once with the runtime message when started, keyed by name', () => { @@ -149,12 +149,12 @@ describe('named convenience shims', () => { it('xhrInterceptor shim fixes its name', () => { const logger = fakeLogger(); - const i = createXhrInterceptorShim({ runtime: 'deno', logger }); + const i = createXhrInterceptorShim({ runtime: 'bun', logger }); expect(i.name).toBe('xhrInterceptor'); i.start(); expect(logger.warnOnce).toHaveBeenCalledWith( 'shim:xhrInterceptor', - 'xhrInterceptor is a no-op on deno; ignored', + 'xhrInterceptor is a no-op on bun; ignored', ); }); }); diff --git a/packages/integration-shims/src/index.ts b/packages/integration-shims/src/index.ts index caadebca9..085eb76dd 100644 --- a/packages/integration-shims/src/index.ts +++ b/packages/integration-shims/src/index.ts @@ -1,7 +1,7 @@ // @bugsee/integration-shims — no-op stand-ins for DOM-only integrations on DOM-less runtimes // Some capture integrations exist only with a DOM: viewHierarchyProvider // (DOM snapshot), breadcrumbsProvider (clicks/keys/history), xhrInterceptor. On Cloudflare / Vercel -// Edge / workers / Node / bun / deno those can't run, so the non-browser platform packages re-export +// Edge / workers / Node / bun those can't run, so the non-browser platform packages re-export // these typed no-ops: user code that references e.g. `viewHierarchyProvider` still type-checks, and // instead of an opaque crash the SDK emits a friendly ONE-TIME debug.warn when the feature is actually // used. Each shim is a structurally-valid CaptureProvider / Interceptor that does nothing but warn. diff --git a/packages/koa/README.md b/packages/koa/README.md index de0798b8b..5259b0df7 100644 --- a/packages/koa/README.md +++ b/packages/koa/README.md @@ -1,6 +1,6 @@ # @bugsee/koa -Koa adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for Koa apps on Node.js, Bun and Deno. +Koa adapter for the Bugsee SDK: per-request context, `http.server` tracing and error reporting for Koa apps on Node.js and Bun. Part of the Bugsee JavaScript SDK (public beta, 0.1.0-beta.x). diff --git a/packages/koa/src/index.ts b/packages/koa/src/index.ts index 9fe445359..db0243ddd 100644 --- a/packages/koa/src/index.ts +++ b/packages/koa/src/index.ts @@ -1,6 +1,6 @@ // @bugsee/koa — Koa middleware adapter. // A single middleware over the per-request context foundation. koa is a PEER (structural types only). -// Works on node/bun/deno-hosted Koa (wherever the launched @bugsee/node client provides the context store). +// Works on node/bun-hosted Koa (wherever the launched @bugsee/node client provides the context store). // Single-install re-export: surface the full public SDK (launch, Bugsee, options + manual-API // types) so users install only `@bugsee/koa` and import everything from one place. diff --git a/packages/node-utils/README.md b/packages/node-utils/README.md index 633a8d838..5d2786b91 100644 --- a/packages/node-utils/README.md +++ b/packages/node-utils/README.md @@ -4,15 +4,15 @@ Node.js building blocks of the Bugsee JavaScript SDK: an HTTP transport and file Part of the Bugsee JavaScript SDK (public beta, 0.1.0-beta.x). -This is an internal building block of the Bugsee SDK, not intended to be installed directly. Install `@bugsee/node` (or `@bugsee/bun` / `@bugsee/deno`), or the umbrella `@bugsee/bugsee` instead. +This is an internal building block of the Bugsee SDK, not intended to be installed directly. Install `@bugsee/node` (or `@bugsee/bun`), or the umbrella `@bugsee/bugsee` instead. ## What it contains - A `node:http` / `node:https` transport for uploads. - File-system storage and a durable bundle store for captured data. -- Hashing and worker-thread helpers shared by the Node.js, Bun and Deno platforms (requires Node.js 18 or newer). +- Hashing and worker-thread helpers shared by the Node.js and Bun platforms (requires Node.js 18 or newer). -It is used by `@bugsee/node`, `@bugsee/bun` and `@bugsee/deno`. Its API is internal and may change between releases. +It is used by `@bugsee/node` and `@bugsee/bun`. Its API is internal and may change between releases. ## Links diff --git a/packages/node-utils/src/batched-fs-chunk-storage.test.ts b/packages/node-utils/src/batched-fs-chunk-storage.test.ts index d9f16e83d..fb5b3a69b 100644 --- a/packages/node-utils/src/batched-fs-chunk-storage.test.ts +++ b/packages/node-utils/src/batched-fs-chunk-storage.test.ts @@ -483,7 +483,7 @@ describe('createBatchedFsChunkStorage', () => { // // appends: 20000 x 425B = 8.1 MiB · writev attempts: 19998 · onError invocations: 19998 · heap: 12.2 MiB // -// This is the DEFAULT node/bun/deno write path, and the documented contract binds it the other way: +// This is the DEFAULT node/bun write path, and the documented contract binds it the other way: // "fixed ring, drop-oldest under overload (no // elastic growth)". The worker ring honours that; the shipped inline default did not. An SDK that OOMs // its host on a full disk alters host behaviour, which this repo treats as a binding prohibition. diff --git a/packages/node-utils/src/bundle-store.ts b/packages/node-utils/src/bundle-store.ts index 831bcc537..2bf2a396f 100644 --- a/packages/node-utils/src/bundle-store.ts +++ b/packages/node-utils/src/bundle-store.ts @@ -6,7 +6,7 @@ import { writeFully } from './write-fully'; // Node implementation of core's BundleStore (the durable bundle queue's storage) — one // owner-only (0o600) file per pending bundle under `dir`, named `.bundle`. @bugsee/node points -// the durable upload pipeline at this; bun and electron-main reuse it (deno ships a Deno.* store). +// the durable upload pipeline at this; bun and electron-main reuse it. // The directory must be STABLE across launches (not per-generation) so recover() can re-upload what a // prior run left behind. Ids are assumed filename-safe (the pipeline's default ids are digits/dashes). diff --git a/packages/node-utils/src/capture-ring-drainer.ts b/packages/node-utils/src/capture-ring-drainer.ts index 3ad5f0a2a..34100f612 100644 --- a/packages/node-utils/src/capture-ring-drainer.ts +++ b/packages/node-utils/src/capture-ring-drainer.ts @@ -1,7 +1,7 @@ import type { RingConsumer } from './capture-ring'; // RingDrainer — the worker-side core of the write path. It drains the shared CaptureRing -// (peek → writev → consume) to per-file fds the WORKER owns (deno can't inherit the main's fds, so the worker +// (peek → writev → consume) to per-file fds the WORKER owns (the main's fds can't be inherited, so the worker // opens them itself), demuxing by `pathId`. Kept PURE over injected fs ops so it is fully unit-testable; the // thin worker_threads glue (the real openSync-by-derived-path / writevSync / closeSync + the Atomics loop) // wraps it and is validated by the adverse-I/O e2e (the ANR-worker precedent). diff --git a/packages/node-utils/src/capture-ring-writer.ts b/packages/node-utils/src/capture-ring-writer.ts index 3f2e0e54f..d7e77441c 100644 --- a/packages/node-utils/src/capture-ring-writer.ts +++ b/packages/node-utils/src/capture-ring-writer.ts @@ -15,7 +15,7 @@ import { ensureDir, listFiles, readFileBytes, remove, writeFileSecure } from './ // CaptureRingWriter — the ChunkStorage over the shared CaptureRing + a RingWorker. // It is a drop-in for the Phase-1 batched writer (identical on-disk layout + tab-frame), but the per-entry // HOT path encodes the frame IN PLACE into the shared ring (zero-copy) and a WORKER drains it to disk off -// the host thread. The worker OWNS all data-file fds (deno can't inherit the main's fds), so the main talks +// the host thread. The worker OWNS all data-file fds (the main's fds can't be inherited), so the main talks // to it by path-derived `pathId` (in the ring) + a tiny control surface (flushAndWait / closeChunk / closeAll // / stop). The infrequent main-thread parts — meta writes, reads, directory listing/removal — stay on the // main thread; reads/seals first flush-and-ack so the worker's writes are on disk. diff --git a/packages/node-utils/src/fs-chunk-storage.ts b/packages/node-utils/src/fs-chunk-storage.ts index bc6ab3bfe..b8ac8d772 100644 --- a/packages/node-utils/src/fs-chunk-storage.ts +++ b/packages/node-utils/src/fs-chunk-storage.ts @@ -14,7 +14,7 @@ import { // one per chunk (names zero-padded so a lexical listing sorts numerically), each holding a `meta` file // plus one append-only data file per source/FileType. Owner-only (0o600/0o700) via fs-storage; deleting // a chunk or generation is a single recursive `remove` of its directory. @bugsee/node passes this to -// createFileCaptureStore; bun and electron-main reuse it (deno ships a Deno.* equivalent). +// createFileCaptureStore; bun and electron-main reuse it. const GEN_PAD = 13; const CHUNK_PAD = 12; diff --git a/packages/node-utils/src/worker-ring-worker.ts b/packages/node-utils/src/worker-ring-worker.ts index c5416622f..5feaf8615 100644 --- a/packages/node-utils/src/worker-ring-worker.ts +++ b/packages/node-utils/src/worker-ring-worker.ts @@ -175,7 +175,7 @@ export function createWorkerThreadRingWorker( worker.unref?.(); // never let the I/O worker keep the host process alive // Block the host thread until the worker has drained up to OUR request token (bounded). Atomics.wait on the - // main thread is permitted on node/bun/deno (verified by a spike). Only the rare read/seal/dispose paths call this. + // main thread is permitted on node/bun (verified by a spike). Only the rare read/seal/dispose paths call this. const flushAndWait = (timeoutMs: number): void => { const req = Atomics.add(fl, FLUSH_REQ, 1) + 1; const deadline = Date.now() + timeoutMs; diff --git a/packages/node/README.md b/packages/node/README.md index abcbef11a..1a2a2bb3f 100644 --- a/packages/node/README.md +++ b/packages/node/README.md @@ -6,7 +6,7 @@ Part of the Bugsee JavaScript SDK (public beta, 0.1.0-beta.x). This is an internal building block of the Bugsee SDK, not intended to be installed directly. Install `@bugsee/bugsee` instead. It selects this build automatically on Node.js and adds performance monitoring, trace propagation and OpenTelemetry on top of it. -The backend adapters (`@bugsee/express`, `@bugsee/fastify`, `@bugsee/nestjs`, `@bugsee/hono`, `@bugsee/koa`, `@bugsee/hapi`, `@bugsee/elysia`), the Next.js and other meta-framework adapters, `@bugsee/bun`, `@bugsee/deno` and `@bugsee/electron` also build on it. Requires Node.js 18 or newer. +The backend adapters (`@bugsee/express`, `@bugsee/fastify`, `@bugsee/nestjs`, `@bugsee/hono`, `@bugsee/koa`, `@bugsee/hapi`, `@bugsee/elysia`), the Next.js and other meta-framework adapters, `@bugsee/bun` and `@bugsee/electron` also build on it. Requires Node.js 18 or newer. What it contains: diff --git a/packages/node/src/data-location.ts b/packages/node/src/data-location.ts index 378032d19..39558e10f 100644 --- a/packages/node/src/data-location.ts +++ b/packages/node/src/data-location.ts @@ -1,7 +1,7 @@ import { lstatSync, mkdirSync } from 'node:fs'; import { dirname, join } from 'node:path'; -// Where the Node SDK stores captured data (server write-path). On servers (node/bun/deno) durable +// Where the Node SDK stores captured data (server write-path). On servers (node/bun) durable // disk capture is the DEFAULT — opt-out, not opt-in — so a crash/OOM that beats the bundle assembly still // delivers the last recording window on the next launch. `'memory'` opts out to the legacy in-RAM path. // When disk is on but no `dataDir` was given, the data lives under `os.tmpdir()/bugsee/` diff --git a/packages/node/src/event-loop-watchdog.ts b/packages/node/src/event-loop-watchdog.ts index c3d022f78..03c3a120b 100644 --- a/packages/node/src/event-loop-watchdog.ts +++ b/packages/node/src/event-loop-watchdog.ts @@ -91,7 +91,7 @@ export interface EventLoopWatchdog { // the loop resumes. The escalation/dedup logic is on the main thread (see the message handler below). // // worker_threads is loaded in a way that works whether the eval'd worker runs in a CJS context (Node: -// `require` is a function) or an ESM context (Deno's node-compat data:-URL worker: only dynamic `import`). +// `require` is a function) or an ESM context (a data:-URL worker where only dynamic `import` works). // A failed load is swallowed (`.catch`) so an unsupported runtime degrades to a silent no-op rather than // throwing an UNHANDLED worker error into the host app. const WORKER_SCRIPT = ` diff --git a/packages/node/src/fetch-server-wrap.test.ts b/packages/node/src/fetch-server-wrap.test.ts index 3aa81338f..c956467bf 100644 --- a/packages/node/src/fetch-server-wrap.test.ts +++ b/packages/node/src/fetch-server-wrap.test.ts @@ -231,7 +231,7 @@ describe('wrapFetchHandler', () => { expect(txn.finish).toHaveBeenCalledWith('OK'); }); - it('forwards extra runtime args (the Bun server / Deno info 2nd arg) to the handler', async () => { + it('forwards extra runtime args (the Bun server 2nd arg) to the handler', async () => { const client = fakeClient({ perf: { startTransaction: vi.fn(() => fakeTxn()) } }); const sentinel = { runtimeArg: true }; let received: unknown; diff --git a/packages/node/src/fetch-server-wrap.ts b/packages/node/src/fetch-server-wrap.ts index 304d33ee6..7c427910e 100644 --- a/packages/node/src/fetch-server-wrap.ts +++ b/packages/node/src/fetch-server-wrap.ts @@ -5,13 +5,12 @@ import { } from './server-instrument'; // Shared fetch-style server instrumentation. -// A `Request → Response` handler is the native server shape on Bun (`Bun.serve({fetch})`) and Deno -// (`Deno.serve(handler)`) — and a future edge/Workers runtime. `wrapFetchHandler` decorates such a handler +// A `Request → Response` handler is the native server shape on Bun (`Bun.serve({fetch})`) — and a future edge/Workers runtime. `wrapFetchHandler` decorates such a handler // so it opens a per-request context + an http.server transaction via the shared `runServerRequest` core // (run-scoped), finishes from the returned Response's status, and — unlike the node:http emit path — CAN -// capture a thrown handler error (it round-trips through this wrap; verified on Bun 1.3 + Deno 2.0+). The +// capture a thrown handler error (it round-trips through this wrap; verified on Bun 1.3). The // error is re-thrown so the runtime's own handling (a 500, or the user's error/onError callback) still -// runs. @bugsee/bun and @bugsee/deno reuse this; they only differ in how they reach + replace their global. +// runs. @bugsee/bun reuses this; it only differs in how it reaches + replaces its global. /** The minimal structural `Request` the wrap reads (no DOM/undici import). */ export interface FetchRequestLike { diff --git a/packages/node/src/http-server-interceptor.ts b/packages/node/src/http-server-interceptor.ts index dbcb781d2..cd17d1d4e 100644 --- a/packages/node/src/http-server-interceptor.ts +++ b/packages/node/src/http-server-interceptor.ts @@ -79,7 +79,7 @@ const applyReturnHeaders = (span: ServerRequestSpan, res: ServerResponseLike): v /** An installable server instrumentation — `install()`/`uninstall()` are idempotent and driven by * launch/stop. The shared shape for the node:http patch AND the per-runtime native serve wraps - * (Bun.serve/Deno.serve) that platforms inject via the launch seam. */ + * (Bun.serve) that platforms inject via the launch seam. */ export interface ServerInstallable { install(): void; uninstall(): void; diff --git a/packages/node/src/launch.test.ts b/packages/node/src/launch.test.ts index 13503b67d..d12cb80e5 100644 --- a/packages/node/src/launch.test.ts +++ b/packages/node/src/launch.test.ts @@ -1672,7 +1672,7 @@ describe('launch — system trace producers', () => { it.each([ { label: 'lag measured', over: {} }, - { label: 'lag opted out (Deno)', over: { measuresEventLoopDelay: false } }, + { label: 'lag opted out', over: { measuresEventLoopDelay: false } }, ])('the producers ($label) attach nothing when captureSystemTraces is false, and release everything on stop()', async ({ over, }) => { @@ -3695,7 +3695,7 @@ describe('launch — local variables (opt-in)', () => { it('lets a seam passed INSIDE the option beat the one launch supplies', () => { // Spread order decides this, and getting it backwards is silent: the caller's clock would be // overwritten by launch's and the option would look accepted while doing nothing. It is the same - // hazard that made `captureLocalVariables: false` have to go AFTER `...options` on deno and bun. + // hazard that made `captureLocalVariables: false` have to go AFTER `...options` on bun. const inspector = fakeInspector(); const intervals: Array<() => void> = []; let ownNow = 0; diff --git a/packages/node/src/launch.ts b/packages/node/src/launch.ts index 910b1c5ac..56b8ef36d 100644 --- a/packages/node/src/launch.ts +++ b/packages/node/src/launch.ts @@ -384,7 +384,7 @@ export interface BugseeLaunchOptions { /** Max captured data kept in the rolling buffer, in megabytes (memory/disk bound). Default 50. */ maxDataSize?: number; /** - * Where the rolling capture buffer lives: `'disk'` (the default on node/bun/deno — durable capture out of + * Where the rolling capture buffer lives: `'disk'` (the default on node/bun — durable capture out of * the box, so a crash/OOM that beats bundle assembly still delivers the recording on the next launch) or * `'memory'` (the legacy in-RAM path, no disk/recovery). On disk with no `dataDir`, data lives under * `os.tmpdir()/bugsee`. @@ -477,8 +477,8 @@ export interface BugseeLaunchOptions { * PER-LAUNCH ONLY: producers are stateful — a producer's `start()` is a no-op while it is already started — * so build a fresh set for each launch (it is RESET on relaunch). A producer instance already owned by another * running client is skipped and reported through `onError` when one is supplied (first owner wins; ownership is released on stop). - * On Bun/Deno a caller-supplied `systemTraceProducers` (or `systemMetricsSampler`) REPLACES the runtime's - * default set, including its gates (e.g. Deno's event-loop-lag opt-out), so pass + * On Bun a caller-supplied `systemTraceProducers` (or `systemMetricsSampler`) REPLACES the runtime's + * default set, including its gates (e.g. an event-loop-lag opt-out), so pass * `createNodeSystemTraceProducers({ measuresEventLoopDelay: false, … })` yourself there. */ systemTraceProducers?: readonly TraceProducer[]; @@ -522,8 +522,8 @@ export interface BugseeLaunchOptions { instrumentIncomingRequests?: boolean; /** * Additional server instrumentations installed (when `instrumentIncomingRequests` is on) AFTER node's own - * node:http interceptor — the seam `@bugsee/bun` / `@bugsee/deno` use to inject their native Bun.serve / - * Deno.serve wraps. Concatenated (not spread-replaced), so a caller's array never drops the platform's. + * node:http interceptor — the seam `@bugsee/bun` uses to inject its native Bun.serve + * wrap. Concatenated (not spread-replaced), so a caller's array never drops the platform's. */ serverInstrumentations?: ServerInstallable[]; /** The node:http server interceptor (advanced / tests — avoids patching the real prototype). Default the real one. */ @@ -695,7 +695,7 @@ function buildLaunch(appToken: string, options: BugseeLaunchOptions = {}): Launc // The PUT checksum digest. Core's default is @bugsee/util's WebCrypto-only `sha256Hex` (util ships in // browser/edge bundles, so it cannot name `node:crypto`); where this runtime has no `crypto.subtle` // (unflagged Node 18, Electron mains on it) node supplies the `node:crypto` digest instead. Inherited by - // bun, deno and electron main, which all compose this launch. + // bun and electron main, which all compose this launch. const baseUploadPipeline = createUploadPipeline({ api, uploader, @@ -1088,7 +1088,7 @@ function buildLaunch(appToken: string, options: BugseeLaunchOptions = {}): Launc }); // Opt-in disk space: the volume the SDK's data dir lives on, so only when there IS one (an in-memory or // degraded launch has none, and never falls back to `/` or the cwd). Appended to caller-supplied producers - // too: the option is an explicit request, and Bun/Deno build their own producer list. NOT built when the legacy + // too: the option is an explicit request, and Bun builds its own producer list. NOT built when the legacy // `systemMetricsSampler` replaces the producer list: it would never be started, and merely building it touches // the shared per-volume tracker. const traceProducers = @@ -1117,9 +1117,9 @@ function buildLaunch(appToken: string, options: BugseeLaunchOptions = {}): Launc ); // The `gc` event rides the SAME per-process tracker as the traces (it owns the one GC observer and arms it only // while a `gc` listener exists). Merely resolving it is free; the source subscribes only once events are captured. - // Bun/Deno's `measuresGc:false` (set when their producer set was built) lives in that shared tracker. + // Bun's `measuresGc:false` (set when its producer set was built) lives in that shared tracker. const nodeEventsSource = createNodeSystemEventsSource(proc, { - // No seams handed over here: the producer set (built above, or by Bun/Deno) already bound this launch's, and a + // No seams handed over here: the producer set (built above, or by Bun) already bound this launch's, and a // second bind would clobber a producer set's own timer seam. processTracker: processTrackerFor({}, options.onError), ...(options.onError !== undefined ? { onError: options.onError } : {}), @@ -1404,7 +1404,7 @@ function buildLaunch(appToken: string, options: BugseeLaunchOptions = {}): Launc } // Incoming-server auto-instrumentation (ON BY DEFAULT; `instrumentIncomingRequests: false` opts out). When on, install the node:http emit patch + any injected native serve - // wraps (bun/deno). getClient is lazy (the carrier client, resolved per request, so install order vs + // wraps (bun). getClient is lazy (the carrier client, resolved per request, so install order vs // setCarrierClient does not matter). One patch per process — launch is a per-process singleton, so this // install runs once; uninstalled on stop(). The framework adapters coexist via first-owner-wins // re-entrancy (the owner here run-scopes the context + http.server txn; an adapter refines it). @@ -1561,7 +1561,7 @@ function buildLaunch(appToken: string, options: BugseeLaunchOptions = {}): Launc } chunkStorage?.dispose?.(); // flush + close the batched writer's handles for (const installable of serverInstallables) { - installable.uninstall(); // restore http.Server.prototype / Bun.serve / Deno.serve + installable.uninstall(); // restore http.Server.prototype / Bun.serve } clearCarrierClient(publicClient, carrier); const stopping = stopCore(timeout) diff --git a/packages/node/src/local-variables.test.ts b/packages/node/src/local-variables.test.ts index 61d144712..d5a992cd0 100644 --- a/packages/node/src/local-variables.test.ts +++ b/packages/node/src/local-variables.test.ts @@ -560,7 +560,7 @@ describe('createInspectorSession — refusing to fight another debugger', () => describe('createInspectorSession', () => { it('returns a usable session on a runtime that has node:inspector', () => { // Loaded lazily rather than by static import, because @bugsee/node's composition is reused verbatim - // by the Bun and Deno tiers and a missing module must not break package load for a feature that is + // by the Bun tier and a missing module must not break package load for a feature that is // off by default. const session = createInspectorSession(); expect(session).toBeDefined(); diff --git a/packages/node/src/local-variables.ts b/packages/node/src/local-variables.ts index 02c849046..f4b1fa7c0 100644 --- a/packages/node/src/local-variables.ts +++ b/packages/node/src/local-variables.ts @@ -794,7 +794,7 @@ export function attachLocals( * The real `node:inspector` session, or undefined where there isn't one. * * Loaded through `createRequire` rather than a static import ON PURPOSE: `@bugsee/node`'s composition is - * reused verbatim by the Bun and Deno tiers, and Bun's debugger support is not the same as Node's. A + * reused verbatim by the Bun tier, and Bun's debugger support is not the same as Node's. A * static import would make the whole package fail to load on a runtime that lacks the module, to * deliver a feature that is off by default. */ @@ -833,7 +833,7 @@ export function createInspectorSession( return new inspector.Session(); } catch { /* v8 ignore next -- unreachable on Node, where these tests run: `node:inspector` is a builtin, so - this is the Bun/Deno degradation path and reaching it would mean faking `createRequire` itself. */ + this is the Bun degradation path and reaching it would mean faking `createRequire` itself. */ return undefined; // no inspector here — the capture degrades to inert } } diff --git a/packages/node/src/server-instrument.test.ts b/packages/node/src/server-instrument.test.ts index 52f6b11a7..41651483a 100644 --- a/packages/node/src/server-instrument.test.ts +++ b/packages/node/src/server-instrument.test.ts @@ -140,7 +140,7 @@ describe('openServerRequest', () => { it('redacts secrets in the request URL before they reach `http.url`', () => { // `info.url` is the raw request target, and its own doc comment claimed "the redaction // pipeline scrubs query secrets" — it did not. This is - // the shared core behind node/bun/deno http AND express/fastify/koa/hapi/elysia, so it is the one + // the shared core behind node/bun http AND express/fastify/koa/hapi/elysia, so it is the one // place that has to be right. const store = fakeStore(); const client = fakeClient({ store, perf: { startTransaction: vi.fn(() => fakeTxn()) } }); diff --git a/packages/node/src/server-instrument.ts b/packages/node/src/server-instrument.ts index 686c7ec46..d41907fb5 100644 --- a/packages/node/src/server-instrument.ts +++ b/packages/node/src/server-instrument.ts @@ -282,7 +282,7 @@ const safeGetClient = (getClient: () => BugseeClient | undefined): BugseeClient // `http.url` is the inbound request target and rides into reports and the `http.server` span. It carries // whatever the client sent — including `?api_key=…` — so it is redacted here, at the one point every -// server path (node/bun/deno http, and the express/fastify/koa/hapi/elysia adapters) funnels through. +// server path (node/bun http, and the express/fastify/koa/hapi/elysia adapters) funnels through. const buildContext = (info: ServerRequestInfo, newContextId: () => string): RequestContext => ({ contextId: newContextId(), attributes: { 'http.method': info.method, 'http.url': sanitizeUrl(info.url) }, @@ -413,7 +413,7 @@ export function runServerRequest( } // The sink itself is host-supplied and may throw. Unguarded it re-opened the exact hole this function // exists to close: the throw escaped into the request AND `dispatch` below never ran. Reproduced - // through the public `wrapFetchHandler` (Bun/Deno): `handlerRan=0`. + // through the public `wrapFetchHandler` (Bun): `handlerRan=0`. try { options.onError?.(error); } catch { diff --git a/packages/node/src/system-events.test.ts b/packages/node/src/system-events.test.ts index dc14cb2e8..7d08671fe 100644 --- a/packages/node/src/system-events.test.ts +++ b/packages/node/src/system-events.test.ts @@ -436,7 +436,7 @@ describe('gc system event (C15)', () => { expect(tick).toBeUndefined(); }); - it('measuresGc:false on the tracker (Bun/Deno): the observer is never constructed and no gc event is ever emitted', () => { + it('measuresGc:false on the tracker (Bun): the observer is never constructed and no gc event is ever emitted', () => { let constructed = 0; class Counting { constructor() { diff --git a/packages/node/src/system-events.ts b/packages/node/src/system-events.ts index f7949fae7..7c1424edb 100644 --- a/packages/node/src/system-events.ts +++ b/packages/node/src/system-events.ts @@ -26,7 +26,7 @@ import { markOwnHandler, releaseSignalToDefault } from './process-policy'; // GC (`gc`, JS-specific, params {count, pauseMs, maxPauseMs}): one event per sampling interval that had at least one // collection; a quiet interval writes NOTHING (omit, never zero). The tracker OWNS the single GC observer and arms // it only while a `gc` listener exists, so this source subscribes LAZILY (first event subscriber) and releases on -// stop: with `captureSystemEvents:false` nothing is ever attached. Bun/Deno gate the tracker's gc source off +// stop: with `captureSystemEvents:false` nothing is ever attached. Bun gates the tracker's gc source off // (`measuresGc:false`: their observer is blind), so the stage never emits there. const DEFAULT_SIGNALS = ['SIGTERM', 'SIGINT'] as const; diff --git a/packages/node/src/trace-producers.ts b/packages/node/src/trace-producers.ts index 70bd456db..33c9555de 100644 --- a/packages/node/src/trace-producers.ts +++ b/packages/node/src/trace-producers.ts @@ -141,8 +141,8 @@ class MemoryLimitProducer extends StageProducer<'memoryLimit'> { /** * The tracker seams plus the platform GATES (`measuresEventLoopDelay`, `measuresV8Heap`, `measuresConstrainedMemory`, - * `measuresGc` (gates the `gc` EVENT source, not a trace); see {@link ProcessTrackerEnv}) — runtime-identity facts the platform packages pass in: Deno gates the - * event-loop histogram, Bun the V8 heap, Bun and Deno the cgroup cap off Linux, both the GC reader (Bun also sets `readsProcMeminfo`). + * `measuresGc` (gates the `gc` EVENT source, not a trace); see {@link ProcessTrackerEnv}) — runtime-identity facts the platform packages pass in: Bun gates the + * V8 heap, the cgroup cap off Linux and the GC reader (Bun also sets `readsProcMeminfo`). */ export interface NodeTraceProducerDeps extends ProcessTrackerEnv { onError?: (error: unknown) => void; diff --git a/packages/protocol/src/upload-contract.test.ts b/packages/protocol/src/upload-contract.test.ts index cea3a3df7..f71c105a1 100644 --- a/packages/protocol/src/upload-contract.test.ts +++ b/packages/protocol/src/upload-contract.test.ts @@ -68,7 +68,7 @@ describe('upload-contract.schema.json ↔ TypeScript wire contract', () => { it('declares the browser block, and does NOT require it — only browser tiers have one', () => { // The backend has had `environment.browser` declared for far longer than this SDK filled it - // (appserver _environment.js). The web tier fills it now; node/bun/deno/edge must keep omitting + // (appserver _environment.js). The web tier fills it now; node/bun/edge must keep omitting // it, so it is a declared-but-optional property rather than a required one. const env = schema.definitions.environmentEnvelope as { required: string[]; diff --git a/packages/protocol/src/wire.ts b/packages/protocol/src/wire.ts index 957abb938..a1e94e1bf 100644 --- a/packages/protocol/src/wire.ts +++ b/packages/protocol/src/wire.ts @@ -62,7 +62,7 @@ export type ReportingTriggerType = export interface EnvironmentEnvelope { /** * The OS the runtime is hosted on. `type` is the OS name and `version` its release — the pair the - * backend reads as the platform key and `os_version`. Runtimes with real OS access (node/bun/deno, + * backend reads as the platform key and `os_version`. Runtimes with real OS access (node/bun, * Electron main) fill these from `os`; the WEB tier derives them in-browser from * `navigator.userAgentData.platform` plus a user-agent parse (see @bugsee/browser's user-agent.ts). * Only the EDGE tiers have no OS to name at all and keep the isolate's own tag ('workers', …). diff --git a/packages/trackers/README.md b/packages/trackers/README.md index 040639ab2..20874878f 100644 --- a/packages/trackers/README.md +++ b/packages/trackers/README.md @@ -26,7 +26,7 @@ The `./browser` entry exports the `ApplicationTracker` (`applicationTrackerFor`, Page zoom: the `UiTracker` `screenSize` state carries `zoom` and `deviceScale` (`devicePixelRatio / zoom`) only when the derivation is trusted: Chromium, the top-level window, a pointer-fine device, and `outerWidth / innerWidth` within 1.5% of a browser zoom preset (it is snapped to the preset). Otherwise both are omitted and consumers use `devicePixelRatio` alone (docked DevTools, custom zoom, Firefox and Safari). Electron key window: `ElectronApplicationTracker.keyWindowBounds()` (focused window, else most recently focused, else the first visible/created one; new `windowMoved` stage) feeds `ElectronDisplayTracker`'s `keyWindowBounds` seam, which numbers `displays` ids statelessly (key window's display is `0`, the rest ascending by Electron id). -The `./node` entry is shared by Node, Bun and Deno and exports the process `ProcessTracker` (`processTrackerFor`, `resetProcessTracker`; a per-process singleton, keyed on the `process` object by default). Its eight stages (`memory`, `systemMemory`, `cpu`, `eventLoop`, `utilization`, `gc`, `v8Heap`, `memoryLimit`) are each armed only while they have listeners, behind one shared sampling timer. The `utilization` stage reports `{ utilizationPercent }` (percent 0-100, one decimal, of the window the loop was not idle; `createGuardedElu` converts perf_hooks' 0..1 fraction). The `gc` stage feeds the `gc` system event (not a trace). A stage the runtime cannot honestly measure emits nothing rather than zero (event-loop utilization on Bun/Deno is dropped by its own tell, idle and active both zero; the event-loop delay histogram on Deno, the GC observer on Bun/Deno, and the V8 heap on Bun are gated by the `measures*` flags the platform packages pass in). `systemMemory.free` is memory available to new work in bytes (Android `availMem`): Electron `process.getSystemMemoryInfo()` or Deno `systemMemoryInfo().available` on macOS first, then `/proc/meminfo` MemAvailable where `readsProcMeminfo` is true (Bun only), then, on macOS only, a rare async `/usr/bin/vm_stat` read (free + file-backed + purgeable pages, the same definition as Electron's `getSystemMemoryInfo`; absolute path, no shell, 2 s timeout, at most one read per 10 s, value served for at most two intervals, single in-flight, killed when the stage loses its last listener, failures omit and are reported once per streak; opt out with `readsVmStat: false`, e.g. `launch(token, { systemTraceProducers: createNodeSystemTraceProducers({ readsVmStat: false }) })`; on Deno it spawns via `Deno.Command` only when the `run` permission for `/usr/bin/vm_stat` is already granted (never prompting), else `Deno.systemMemoryInfo().available`, a larger free+inactive estimate; an unarmed `current()` reads the cache only; a hung child can delay process exit by up to the 2 s timeout; macOS is mostly a developer platform and the spawn happens only while the stage has a listener), then `os.freemem()` (not on macOS, where it is free pages only). It is omitted whenever no source is plausible. Inside a container it is the host's figure; the cap is `process_memory_limit`. The CPU stage has no start value: it reports from the first tick. Seams merge and are never dropped: a later launch that omits `scheduler` or `onError` keeps the previous launch's, and building a producer set already rebinds the shared tracker, so tests that inject fakes need a private `key` or `resetProcessTracker()`. It also exports the guarded runtime sources it is built from (`createGuardedEventLoopSource`, `createGuardedElu`, `createGcSource`, `createV8HeapReader`, `createMemoryLimitReader`, `createSystemFreeReader`, `createElectronMemoryReader`, `createDenoMemoryReader`, `createProcMeminfoReader`, `parseMemAvailable`). +The `./node` entry is shared by Node and Bun and exports the process `ProcessTracker` (`processTrackerFor`, `resetProcessTracker`; a per-process singleton, keyed on the `process` object by default). Its eight stages (`memory`, `systemMemory`, `cpu`, `eventLoop`, `utilization`, `gc`, `v8Heap`, `memoryLimit`) are each armed only while they have listeners, behind one shared sampling timer. The `utilization` stage reports `{ utilizationPercent }` (percent 0-100, one decimal, of the window the loop was not idle; `createGuardedElu` converts perf_hooks' 0..1 fraction). The `gc` stage feeds the `gc` system event (not a trace). A stage the runtime cannot honestly measure emits nothing rather than zero (event-loop utilization on Bun/Deno is dropped by its own tell, idle and active both zero; the event-loop delay histogram on Deno, the GC observer on Bun/Deno, and the V8 heap on Bun are gated by the `measures*` flags the platform packages pass in). `systemMemory.free` is memory available to new work in bytes (Android `availMem`): Electron `process.getSystemMemoryInfo()` or Deno `systemMemoryInfo().available` on macOS first, then `/proc/meminfo` MemAvailable where `readsProcMeminfo` is true (Bun only), then, on macOS only, a rare async `/usr/bin/vm_stat` read (free + file-backed + purgeable pages, the same definition as Electron's `getSystemMemoryInfo`; absolute path, no shell, 2 s timeout, at most one read per 10 s, value served for at most two intervals, single in-flight, killed when the stage loses its last listener, failures omit and are reported once per streak; opt out with `readsVmStat: false`, e.g. `launch(token, { systemTraceProducers: createNodeSystemTraceProducers({ readsVmStat: false }) })`; on Deno it spawns via `Deno.Command` only when the `run` permission for `/usr/bin/vm_stat` is already granted (never prompting), else `Deno.systemMemoryInfo().available`, a larger free+inactive estimate; an unarmed `current()` reads the cache only; a hung child can delay process exit by up to the 2 s timeout; macOS is mostly a developer platform and the spawn happens only while the stage has a listener), then `os.freemem()` (not on macOS, where it is free pages only). It is omitted whenever no source is plausible. Inside a container it is the host's figure; the cap is `process_memory_limit`. The CPU stage has no start value: it reports from the first tick. Seams merge and are never dropped: a later launch that omits `scheduler` or `onError` keeps the previous launch's, and building a producer set already rebinds the shared tracker, so tests that inject fakes need a private `key` or `resetProcessTracker()`. It also exports the guarded runtime sources it is built from (`createGuardedEventLoopSource`, `createGuardedElu`, `createGcSource`, `createV8HeapReader`, `createMemoryLimitReader`, `createSystemFreeReader`, `createElectronMemoryReader`, `createDenoMemoryReader`, `createProcMeminfoReader`, `parseMemAvailable`). The `./node` entry also exports the disk `StorageTracker` (`storageTrackerFor`, `resetStorageTracker`; one singleton per resolved data directory, so launches over the same directory share a tracker and launches over different directories never affect each other; a launch without a data directory gets the shared inert `process`-keyed tracker, and an explicit `key` overrides, for tests) behind the opt-in `disk_mem_free` / `disk_mem_total` traces. Its one stage, `disk` (`{freeBytes, totalBytes}`), reads the volume of the launch's data directory with `fs.promises.statfs` (not `/` or the working directory) at once when a listener arrives and then on its own unref'd 5 s timer, and does nothing while no one listens, when there is no data directory, or when the runtime has no `statfs`. An unreadable or unsane reading emits nothing (a full disk is a true 0 free), and failures are reported once per failure streak. Within one directory's tracker, `onError`, `scheduler` and `statfs` are latest-launch-wins, an omitted seam keeps the earlier one, and a changed seam is applied (and re-read) immediately. Only the merged seams survive the last unsubscribe; the last reading does not. diff --git a/packages/trackers/package.json b/packages/trackers/package.json index 4e24ed541..f444dd78f 100644 --- a/packages/trackers/package.json +++ b/packages/trackers/package.json @@ -7,7 +7,7 @@ "url": "git+https://github.com/bugsee/bugsee-javascript.git", "directory": "packages/trackers" }, - "description": "Domain-tracker foundation: multi-key emitter, InterceptorBase and the per-window tracker registry, with a ./browser entry (ApplicationTracker, ConnectivityTracker, PowerTracker, ProcessTracker, StorageTracker, UiTracker, EnvironmentTracker, hostRead), a ./node entry shared by Node, Bun and Deno (ProcessTracker, StorageTracker and their guarded runtime sources) and an ./electron entry (the Electron main-process ProcessTracker, PowerTracker, DisplayTracker and ApplicationTracker: app metrics, child-process-gone, the once-only GPU info read, power events, displays and window focus/visibility/renderer hangs)", + "description": "Domain-tracker foundation: multi-key emitter, InterceptorBase and the per-window tracker registry, with a ./browser entry (ApplicationTracker, ConnectivityTracker, PowerTracker, ProcessTracker, StorageTracker, UiTracker, EnvironmentTracker, hostRead), a ./node entry shared by Node and Bun (ProcessTracker, StorageTracker and their guarded runtime sources) and an ./electron entry (the Electron main-process ProcessTracker, PowerTracker, DisplayTracker and ApplicationTracker: app metrics, child-process-gone, the once-only GPU info read, power events, displays and window focus/visibility/renderer hangs)", "type": "module", "main": "./src/index.ts", "types": "./src/index.ts", diff --git a/packages/trackers/src/node/gc-observer.ts b/packages/trackers/src/node/gc-observer.ts index 00636d032..dc322d451 100644 --- a/packages/trackers/src/node/gc-observer.ts +++ b/packages/trackers/src/node/gc-observer.ts @@ -1,8 +1,8 @@ import { PerformanceObserver } from 'node:perf_hooks'; // Lazy GC source: a `PerformanceObserver({entryTypes:['gc']})` that exists only between start() and stop(). -// Measured 2026-09: real entries on Node; BLIND on Bun and Deno (0 entries after heavy churn and forced GC), -// so those runtimes gate it off (`measuresGc: false`) and never even construct the observer — a quiet-looking +// Measured 2026-09: real entries on Node; BLIND on Bun (0 entries after heavy churn and forced GC), +// so that runtime gates it off (`measuresGc: false`) and never even construct the observer — a quiet-looking // zero there would be a lie. export interface GcEntry { diff --git a/packages/trackers/src/node/guarded-event-loop.test.ts b/packages/trackers/src/node/guarded-event-loop.test.ts index fb0c12c53..40f566387 100644 --- a/packages/trackers/src/node/guarded-event-loop.test.ts +++ b/packages/trackers/src/node/guarded-event-loop.test.ts @@ -283,7 +283,7 @@ describe('createGuardedElu', () => { expect(createGuardedElu(fakeElu(0.0004))()).toBe(0); }); - it('is undefined on the Bun/Deno shape (idle and active both 0)', () => { + it('is undefined on the Bun shape (idle and active both 0)', () => { expect(createGuardedElu(() => ({ idle: 0, active: 0, utilization: 0 }))()).toBeUndefined(); }); diff --git a/packages/trackers/src/node/guarded-event-loop.ts b/packages/trackers/src/node/guarded-event-loop.ts index 96afccda3..f827683b8 100644 --- a/packages/trackers/src/node/guarded-event-loop.ts +++ b/packages/trackers/src/node/guarded-event-loop.ts @@ -1,6 +1,6 @@ import { monitorEventLoopDelay, performance } from 'node:perf_hooks'; -// Guarded, LAZY event-loop sources for node-family runtimes with PARTIAL perf_hooks (Bun, Deno). Nothing is +// Guarded, LAZY event-loop sources for node-family runtimes with PARTIAL perf_hooks (Bun). Nothing is // constructed or enabled until start(): a source that is never started costs nothing, and a runtime whose // monitorEventLoopDelay throws degrades to "lag omitted" rather than aborting SDK startup. @@ -31,7 +31,7 @@ export interface Elu { idle?: number; active?: number; } -/** The two perf_hooks primitives the event-loop metrics need (partial on Bun/Deno, so injected). */ +/** The two perf_hooks primitives the event-loop metrics need (partial on Bun, so injected). */ export interface PerfHooks { monitorEventLoopDelay: () => DelayHistogram; eventLoopUtilization: (a?: Elu, b?: Elu) => Elu; @@ -46,9 +46,9 @@ export const realPerfHooks: PerfHooks = { /** * Does this delta mean "the runtime does not implement ELU" rather than "the loop was idle"? * - * `performance.eventLoopUtilization()` exists on Bun and Deno and does not throw — it simply answers + * `performance.eventLoopUtilization()` exists on Bun and does not throw — it simply answers * `{idle:0, active:0, utilization:0}` for ever. Measured 2026-09-01, after a 120ms CPU burn and a 60ms - * sleep: node reported `{idle:61.0, active:0.118}` while Bun and Deno both reported zeros. A throw-guard + * sleep: node reported `{idle:61.0, active:0.118}` while Bun reported zeros. A throw-guard * cannot see that, so the SDK shipped a confident 0% utilization — which reads, to whoever opens the * report, exactly like a perfectly healthy idle process. * @@ -120,7 +120,7 @@ export function createGuardedEventLoopSource(monitor: () => DelayHistogram): Eve // A utilization reader returning PERCENT 0-100 of the window the loop was not idle, one decimal (perf_hooks reports a // 0..1 fraction; the wire unit is percent, like `cpu_usage_process`). `undefined` — NOT zero — whenever the runtime cannot give a real -// reading: it threw, or it answered the Bun/Deno way (idle and active both zero for ever). +// reading: it threw, or it answered the Bun way (idle and active both zero for ever). export function createGuardedElu(elu: PerfHooks['eventLoopUtilization']): () => number | undefined { const toPercent = (fraction: number): number => Math.round(fraction * 1000) / 10; let prev: Elu; diff --git a/packages/trackers/src/node/index.test.ts b/packages/trackers/src/node/index.test.ts index e087b8eab..96d8608d4 100644 --- a/packages/trackers/src/node/index.test.ts +++ b/packages/trackers/src/node/index.test.ts @@ -7,7 +7,6 @@ describe('@bugsee/trackers/node public surface', () => { expect(Object.keys(nodeEntry).sort()).toEqual([ 'ProcessTracker', 'StorageTracker', - 'createDenoMemoryReader', 'createElectronMemoryReader', 'createGcSource', 'createGuardedElu', diff --git a/packages/trackers/src/node/index.ts b/packages/trackers/src/node/index.ts index 35f6b8e3d..d5b25909a 100644 --- a/packages/trackers/src/node/index.ts +++ b/packages/trackers/src/node/index.ts @@ -1,5 +1,5 @@ -// `@bugsee/trackers/node` entry. Platform tracker implementations that need node:* APIs (shared by Node, Bun and -// Deno, which expose a node-compatible surface) live under src/node/ and are exported from here. The portable root +// `@bugsee/trackers/node` entry. Platform tracker implementations that need node:* APIs (shared by Node and +// Bun, which expose a node-compatible surface) live under src/node/ and are exported from here. The portable root // entry and the browser entry must never import from this directory. export { createGcSource, @@ -29,7 +29,6 @@ export { resetProcessTracker, } from './process-tracker'; export { - createDenoMemoryReader, createElectronMemoryReader, createMemoryLimitReader, createProcMeminfoReader, diff --git a/packages/trackers/src/node/process-tracker.test.ts b/packages/trackers/src/node/process-tracker.test.ts index 76c39358a..8b057e033 100644 --- a/packages/trackers/src/node/process-tracker.test.ts +++ b/packages/trackers/src/node/process-tracker.test.ts @@ -498,11 +498,7 @@ describe('ProcessTracker', () => { }); it.each([ - [ - 'eventLoop (Deno: measuresEventLoopDelay:false)', - 'eventLoop', - { measuresEventLoopDelay: false }, - ], + ['eventLoop (measuresEventLoopDelay:false)', 'eventLoop', { measuresEventLoopDelay: false }], ['v8Heap (Bun: measuresV8Heap:false)', 'v8Heap', { measuresV8Heap: false }], [ 'memoryLimit (measuresConstrainedMemory:false)', @@ -592,7 +588,7 @@ describe('ProcessTracker', () => { mk({ systemMemory: undefined, platform: 'linux', ...over }).tracker.current('systemMemory'); const meminfo = () => 'MemAvailable: 2 kB\n'; - it('default: os.freemem(), and /proc/meminfo is never read (Deno must not trigger a permission prompt)', () => { + it('default: os.freemem(), and /proc/meminfo is never read', () => { let reads = 0; const got = free({ freeMemory: () => 7, meminfo: () => (reads++, 'MemAvailable: 2 kB\n') }); expect(got?.free).toBe(7); @@ -606,7 +602,7 @@ describe('ProcessTracker', () => { ).toBe(7); }); - it('a native source (Electron/Deno) wins over every other; it falls through when it has no answer', () => { + it('a native source (Electron) wins over every other; it falls through when it has no answer', () => { const base = { freeMemory: () => 7, readsProcMeminfo: true, meminfo }; expect(free({ ...base, nativeAvailableMemory: () => 5 })?.free).toBe(5); expect(free({ ...base, nativeAvailableMemory: () => undefined })?.free).toBe(2048); @@ -713,92 +709,6 @@ describe('ProcessTracker', () => { expect(reads).toBe(2); }); - describe('on Deno (never prompts)', () => { - const withDeno = ( - state: string, - run: (spawned: () => number, asked: () => number) => void, - ) => { - const g = globalThis as { Deno?: unknown }; - const had = 'Deno' in g; - const prev = g.Deno; - let spawned = 0; - let asked = 0; - g.Deno = { - Command: class { - constructor() { - spawned += 1; - } - output() { - return new Promise(() => {}); - } - }, - permissions: { - querySync: () => { - asked += 1; - return { state }; - }, - }, - systemMemoryInfo: () => ({ available: 999 }), - }; - try { - run( - () => spawned, - () => asked, - ); - } finally { - if (had) g.Deno = prev; - else delete g.Deno; - } - }; - const tickFree = (over: Partial = {}) => { - const { tracker, fs } = mk({ systemMemory: undefined, platform: 'darwin', ...over }); - const events: ProcessEvents['systemMemory'][] = []; - tracker.on('systemMemory', (e) => void events.push(e)); - fs.tick(); - tracker.reset(); - return events.at(-1); - }; - - it('run permission GRANTED: spawns through Deno.Command and does not mix in the larger estimate', () => { - withDeno('granted', (spawned) => { - const got = tickFree(); - expect(spawned()).toBe(1); - expect(got).not.toHaveProperty('free'); // async: no value on the first tick, never the 999 estimate - }); - }); - - it.each([ - 'prompt', - 'denied', - ])('run permission %s: no spawn (so no prompt), Deno systemMemoryInfo answers', (state) => { - withDeno(state, (spawned, asked) => { - expect(tickFree()?.free).toBe(999); - expect(spawned()).toBe(0); - expect(asked()).toBeGreaterThan(0); - }); - }); - - it('an injected spawn function is honoured on Deno regardless of the permission (test seam)', () => { - withDeno('prompt', (spawned) => { - let injected = 0; - const vmStatExecFile = (() => { - injected += 1; - return { kill: () => {} }; - }) as never; - tickFree({ vmStatExecFile }); - expect(injected).toBe(1); - expect(spawned()).toBe(0); - }); - }); - - it('readsVmStat:false on Deno: estimate only, permission never even queried for a spawn', () => { - withDeno('granted', (spawned) => { - expect(tickFree({ readsVmStat: false })?.free).toBe(999); - expect(spawned()).toBe(0); - }); - }); - }); - it.each([ 1000, 10_000, 30_000, 120_000, ])('the value read on one tick is still served on the next at tracker intervalMs=%i (cache life follows the tick)', (intervalMs) => { @@ -885,22 +795,14 @@ describe('ProcessTracker', () => { ); }); - it('default native sources: Electron process.getSystemMemoryInfo() on this process object, Deno systemMemoryInfo on macOS', () => { + it('default native sources: Electron process.getSystemMemoryInfo() on this process object', () => { const proc = nodeProcessForTest as { getSystemMemoryInfo?: unknown }; - const g = globalThis as { Deno?: unknown }; - const hadDeno = 'Deno' in g; - const prevDeno = g.Deno; try { proc.getSystemMemoryInfo = () => ({ available: 3 }); // KiB, linux expect(free({ platform: 'linux', freeMemory: () => 7 })?.free).toBe(3072); delete proc.getSystemMemoryInfo; - g.Deno = { systemMemoryInfo: () => ({ available: 4096 }) }; - expect(free({ platform: 'darwin' })?.free).toBe(4096); - expect(free({ platform: 'linux', freeMemory: () => 7 })?.free).toBe(7); // Deno source is macOS-only } finally { delete proc.getSystemMemoryInfo; - if (hadDeno) g.Deno = prevDeno; - else delete g.Deno; } }); @@ -966,7 +868,7 @@ describe('ProcessTracker', () => { }); }); - it('guarded ELU: a fresh baseline per arming, and Bun/Deno-style flat zeros are omitted, never reported as 0%', () => { + it('guarded ELU: a fresh baseline per arming, and Bun-style flat zeros are omitted, never reported as 0%', () => { let calls = 0; const fs = fakeScheduler(); const tracker = new ProcessTracker({ diff --git a/packages/trackers/src/node/process-tracker.ts b/packages/trackers/src/node/process-tracker.ts index 537a3c52a..2d0772a00 100644 --- a/packages/trackers/src/node/process-tracker.ts +++ b/packages/trackers/src/node/process-tracker.ts @@ -14,27 +14,18 @@ import { realPerfHooks, } from './guarded-event-loop'; import { - createDenoMemoryReader, createElectronMemoryReader, createMemoryLimitReader, createProcMeminfoReader, createSystemFreeReader, createV8HeapReader, - type DenoMemoryInfoLike, type ElectronMemoryInfoLike, firstAnswer, type V8HeapStats, } from './runtime-readers'; -import { - createDenoExecFile, - createVmStatSampler, - type DenoRunLike, - denoVmStatGranted, - type ExecFileLike, - type VmStatSource, -} from './vm-stat'; - -// Node/Bun/Deno PROCESS tracker (domain tracker, design §15.2/§15.3; Android reference: BugseeTrackerProcess). It +import { createVmStatSampler, type ExecFileLike, type VmStatSource } from './vm-stat'; + +// Node/Bun PROCESS tracker (domain tracker, design §15.2/§15.3; Android reference: BugseeTrackerProcess). It // owns everything the runtime can say about its own process, as EIGHT independent stages: // // memory process.memoryUsage() -> { rss, heapTotal, heapUsed, external, arrayBuffers } @@ -54,16 +45,16 @@ import { // `start()`/`stop()` (InterceptorBase) therefore do nothing here. Every tick reads each armed stage on its own and // emits it; a stage whose read throws is reported and drops ONLY itself for that tick. // -// ABSENCE IS NEVER ZERO. A stage whose runtime cannot answer emits nothing: ELU on Bun/Deno (flat idle/active zeros), -// the event-loop histogram when it has no sample yet or when the platform gated it off (Deno's never sees a blocked -// loop), the GC observer where it is blind (Bun/Deno) or refused, the heap/limit/available-memory readers when their +// ABSENCE IS NEVER ZERO. A stage whose runtime cannot answer emits nothing: ELU on Bun (flat idle/active zeros), +// the event-loop histogram when it has no sample yet or when the platform gated it off (a histogram that never sees a blocked +// loop), the GC observer where it is blind (Bun) or refused, the heap/limit/available-memory readers when their // numbers are not true. The platform GATES (`measures*`) are runtime-identity facts the composition root passes in; // the tracker only honours them. An injected source/reader always wins over its gate. // // SINGLETON per key object (see `processTrackerFor`: the `process` object by default). SEAMS MERGE, NEVER DROP: the // tracker outlives launches, so a later launch that omits `scheduler`/`onError`/a reader KEEPS the previous launch's // (it can replace a seam, never shed one). Merely BUILDING a producer set (`createNodeSystemTraceProducers`) rebinds -// the shared tracker, so a Bun/Deno default set built before `...options` in their launch.ts already hands its seams over. +// the shared tracker, so a Bun default set built before `...options` in their launch.ts already hands its seams over. // Tests that inject fakes must use a private `key` or call `resetProcessTracker()`. RETENTION rule — what survives // a stage's last unsubscribe: ONLY the resolved seams, and the "this runtime refused" memory inside the guarded // sources (a refusing histogram/observer is not hammered again until a rebind swaps the seams). Everything windowed @@ -141,32 +132,27 @@ export interface ProcessEnv { freeMemory?: () => number; /** * macOS only: read memory available to new work from `/usr/bin/vm_stat` (a rare async read; see ./vm-stat) when no - * native source answers. Default `true`; `false` is the opt-out (the trace is then omitted on macOS Node/Bun, and - * Deno uses its larger `systemMemoryInfo().available` estimate). On DENO the spawn is made through `Deno.Command` - * and ONLY when `Deno.permissions.querySync({name:'run', command:'/usr/bin/vm_stat'})` is already `granted` (it never - * prompts); otherwise Deno answers `systemMemoryInfo().available` (free + inactive: a larger estimate than the - * vm_stat definition). + * native source answers. Default `true`; `false` is the opt-out (the trace is then omitted on macOS Node/Bun). */ readsVmStat?: boolean; /** Replaces the `vm_stat` sampler (it is stopped when the memory stage loses its last listener). */ vmStat?: VmStatSource; - /** The spawn function for the default `vm_stat` sampler (test seam; default `child_process.execFile`, or `Deno.Command` on Deno). */ + /** The spawn function for the default `vm_stat` sampler (test seam; default `child_process.execFile`)). */ vmStatExecFile?: ExecFileLike; /** * A runtime-native memory-available-to-new-work reader (bytes), tried before every other free-memory source. Default: - * Electron's `process.getSystemMemoryInfo()` when the `process` object has it, else `Deno.systemMemoryInfo()` - * on macOS (feature-detected; absent on plain Node/Bun). + * Electron's `process.getSystemMemoryInfo()` when the `process` object has it (absent on plain Node/Bun). */ nativeAvailableMemory?: () => number | undefined; /** `process.platform` for the free-memory source choice. Default the real one. */ platform?: string; - /** perf_hooks primitives for the event-loop metrics (partial on Bun/Deno). Default node:perf_hooks. */ + /** perf_hooks primitives for the event-loop metrics (partial on Bun). Default node:perf_hooks. */ perfHooks?: PerfHooks; /** Test seam for the GC observer constructor. Default `node:perf_hooks`. */ performanceObserver?: ObserverCtor; /** - * Does this runtime's `monitorEventLoopDelay` observe a BLOCKED loop? Default `true`. Deno's does not (answers, - * never throws, never registers a stall), so `@bugsee/deno` passes `false` and the histogram is never constructed. + * Does this runtime's `monitorEventLoopDelay` observe a BLOCKED loop? Default `true`. A runtime whose histogram + * answers but never registers a stall passes `false`, and the histogram is never constructed. */ measuresEventLoopDelay?: boolean; /** @@ -175,19 +161,18 @@ export interface ProcessEnv { */ measuresV8Heap?: boolean; /** - * Can this runtime truthfully answer `process.constrainedMemory()`? Default `true`. `@bugsee/bun` / `@bugsee/deno` - * pass `false` off Linux, the only platform where a cgroup cap exists and where their answer was measured real - * (Bun 1.4.4 and Deno 2.8.3 in `docker -m`: the cap; unconstrained: Bun total RAM, Deno `0`, Node the 2^64 sentinel). + * Can this runtime truthfully answer `process.constrainedMemory()`? Default `true`. `@bugsee/bun` + * passes `false` off Linux, the only platform where a cgroup cap exists and where its answer was measured real + * (Bun 1.4.4 in `docker -m`: the cap; unconstrained: Bun total RAM, Node the 2^64 sentinel). * The value filter alone decided before; this makes the platform answer explicit, so the trace is omitted, not guessed. */ measuresConstrainedMemory?: boolean; /** * Read `/proc/meminfo` MemAvailable before `os.freemem()` on Linux? Default `false`. Only `@bugsee/bun` sets it - * (Bun < 1.3.13's `os.freemem()` is not MemAvailable). Deno must NOT: its `os.freemem()` already is, and the extra - * read triggers an interactive permission prompt under a scoped `--allow-read`. + * (Bun < 1.3.13's `os.freemem()` is not MemAvailable). */ readsProcMeminfo?: boolean; - /** Does `PerformanceObserver({entryTypes:['gc']})` see collections? Default `true`; blind on Bun/Deno. */ + /** Does `PerformanceObserver({entryTypes:['gc']})` see collections? Default `true`; blind on Bun. */ measuresGc?: boolean; /** Drives the shared sampling timer; default the global timers, unref'd so the tracker never holds a process alive. */ scheduler?: ProcessTimers; @@ -449,35 +434,20 @@ export class ProcessTracker extends InterceptorBase { // `??` / explicit gates (never a spread over defaults): an injected source wins; otherwise the default is wired // only where the runtime can give a true value, and an unwired source means the stage is ABSENT. const platform = env.platform ?? nodeProcess.platform; - // macOS free memory. On Deno the spawn needs the `run` permission and node:child_process would PROMPT for it, so it is - // made through Deno.Command and only when already granted; otherwise Deno's own (larger) estimate answers. - const deno = (globalThis as { Deno?: DenoRunLike & DenoMemoryInfoLike }).Deno; - const injectedSpawn = env.vmStat !== undefined || env.vmStatExecFile !== undefined; + // macOS free memory: the rare async `vm_stat` read (an injected sampler or spawn function wins). const vmStat = platform === 'darwin' && env.readsVmStat !== false ? (env.vmStat ?? createVmStatSampler({ - ...(env.vmStatExecFile !== undefined - ? { execFile: env.vmStatExecFile } - : deno !== undefined && typeof deno.Command === 'function' - ? { execFile: createDenoExecFile(deno) } - : {}), + ...(env.vmStatExecFile !== undefined ? { execFile: env.vmStatExecFile } : {}), // A value read on one tick must still be fresh (<= 2 sampler intervals) on the next tick, so the cache life // follows a slower tracker interval; never faster than 10 s (the spawn cadence). intervalMs: Math.max(VM_STAT_MIN_INTERVAL_MS, env.intervalMs ?? DEFAULT_INTERVAL_MS), onError: (error) => this.#onError(error), })) : undefined; - const denoEstimate = createDenoMemoryReader(deno, platform); - const macFree = (): number | undefined => { - if ( - vmStat !== undefined && - (deno === undefined || injectedSpawn || denoVmStatGranted(deno)) - ) { - return this.#peekOnly ? vmStat.peek() : vmStat.read(); - } - return denoEstimate(); - }; + const macFree = (): number | undefined => + vmStat === undefined ? undefined : this.#peekOnly ? vmStat.peek() : vmStat.read(); const resolved: Resolved = { vmStat, eventLoop: diff --git a/packages/trackers/src/node/runtime-readers.test.ts b/packages/trackers/src/node/runtime-readers.test.ts index fe6fd8477..ccc0e9497 100644 --- a/packages/trackers/src/node/runtime-readers.test.ts +++ b/packages/trackers/src/node/runtime-readers.test.ts @@ -1,6 +1,5 @@ import { describe, expect, it } from 'vitest'; import { - createDenoMemoryReader, createElectronMemoryReader, createMemoryLimitReader, createProcMeminfoReader, @@ -235,24 +234,6 @@ describe('createElectronMemoryReader (KiB -> bytes)', () => { }); }); -describe('createDenoMemoryReader (bytes)', () => { - const deno = { systemMemoryInfo: () => ({ available: 4096 }) }; - it('reports available on macOS only', () => { - expect(createDenoMemoryReader(deno, 'darwin')()).toBe(4096); - expect(createDenoMemoryReader(deno, 'linux')()).toBeUndefined(); - expect(createDenoMemoryReader(deno, 'win32')()).toBeUndefined(); - }); - it('is undefined without Deno/the API or for implausible values', () => { - expect(createDenoMemoryReader(undefined, 'darwin')()).toBeUndefined(); - expect(createDenoMemoryReader({}, 'darwin')()).toBeUndefined(); - for (const bad of [Number.NaN, -1, '5']) { - expect( - createDenoMemoryReader({ systemMemoryInfo: () => ({ available: bad }) }, 'darwin')(), - ).toBeUndefined(); - } - }); -}); - describe('firstAnswer', () => { it('returns the first defined answer, skipping undefined and throwing readers', () => { const boom = () => { diff --git a/packages/trackers/src/node/runtime-readers.ts b/packages/trackers/src/node/runtime-readers.ts index b8297a92a..1c025391a 100644 --- a/packages/trackers/src/node/runtime-readers.ts +++ b/packages/trackers/src/node/runtime-readers.ts @@ -139,27 +139,6 @@ export function createElectronMemoryReader( }; } -/** The slice of Deno's namespace we read. `systemMemoryInfo()` reports BYTES. */ -export interface DenoMemoryInfoLike { - systemMemoryInfo?: () => { available?: unknown }; -} - -/** - * `Deno.systemMemoryInfo().available`, on macOS ONLY (free + inactive pages: the quantity `os.freemem()` lacks there). - * (If it is unavailable, the `vm_stat` source covers macOS.) - * On Linux and Windows Deno's `os.freemem()` is already the available figure, so this source is not consulted. - */ -export function createDenoMemoryReader( - deno: DenoMemoryInfoLike | undefined, - platform: string, -): () => number | undefined { - return () => { - if (platform !== 'darwin' || typeof deno?.systemMemoryInfo !== 'function') return undefined; - const value = deno.systemMemoryInfo().available; - return isCount(value) && value >= 0 ? value : undefined; - }; -} - /** The first of several optional readers that answers; a reader that throws is skipped. */ export function firstAnswer( readers: readonly (() => number | undefined)[], @@ -180,7 +159,7 @@ export function firstAnswer( export interface SystemFreeSources { /** `process.platform`. On `darwin` `os.freemem()` is NOT a source (see {@link createSystemFreeReader}). */ platform: string; - /** A runtime-native "available to new work" figure in BYTES (Electron, Deno on macOS), tried first. */ + /** A runtime-native "available to new work" figure in BYTES (Electron), tried first. */ native?: () => number | undefined; /** Raw `/proc/meminfo` text, only supplied for a runtime whose `os.freemem()` is not MemAvailable (Bun < 1.3.13). */ meminfo?: () => string | undefined; @@ -194,16 +173,15 @@ export interface SystemFreeSources { /** * `ram_system_free`: memory available to new work, as Android reports it (`availMem`), never merely free pages. * Sources in order, first plausible value (finite, >= 0, <= total) wins: - * 1. `native`: Electron `process.getSystemMemoryInfo()`; Deno `systemMemoryInfo().available` on macOS. + * 1. `native`: Electron `process.getSystemMemoryInfo()`. * 2. `meminfo`: `MemAvailable` from `/proc/meminfo` (Bun only). * 3. `vmStat`, on macOS only: free + file-backed + purgeable pages from a RARE async `/usr/bin/vm_stat` read (the * same definition as Electron's `getSystemMemoryInfo`; see ./vm-stat). When it has no fresh value the trace is * omitted for that tick, it never falls back to `os.freemem()`. - * 4. `os.freemem()`, except on macOS. libuv reads `MemAvailable` on Linux (since 1.43, Node >= 16.14; Deno since - * 2023) and `ullAvailPhys` on Windows. On macOS it is only free pages (measured 0.2-0.7% of RAM on a 64 GB Mac + * 4. `os.freemem()`, except on macOS. libuv reads `MemAvailable` on Linux (since 1.43, Node >= 16.14) and `ullAvailPhys` on Windows. On macOS it is only free pages (measured 0.2-0.7% of RAM on a 64 GB Mac * while the vm_stat available estimate was ~29%), so it is not a source there. * `process.availableMemory()` is never used: it equals `os.freemem()` without a cgroup limit, reads lower inside one, - * is 0 on Windows Deno and includes inactive pages on macOS Deno. Inside a container the value is the HOST's + * is lower inside a cgroup. Inside a container the value is the HOST's * figure; the cgroup cap is carried by `process_memory_limit`. * A source that throws or answers an implausible value is skipped; none answering means undefined (omitted). */ diff --git a/packages/trackers/src/node/storage-tracker.ts b/packages/trackers/src/node/storage-tracker.ts index 8b894c3f1..58ebc2322 100644 --- a/packages/trackers/src/node/storage-tracker.ts +++ b/packages/trackers/src/node/storage-tracker.ts @@ -4,7 +4,7 @@ import nodeProcess from 'node:process'; import { InterceptorBase } from '../interceptor-base'; import { createTrackerRegistry } from '../tracker-registry'; -// Node/Bun/Deno STORAGE tracker (domain tracker, design §15.2; Android reference: BugseeTrackerStorage). It owns the +// Node/Bun STORAGE tracker (domain tracker, design §15.2; Android reference: BugseeTrackerStorage). It owns the // disk-space read for ONE directory's volume (the launch's effective data dir, NOT `/` or the cwd) through // `fs.promises.statfs`, and polls it sparsely off the event loop. One stage: // diff --git a/packages/trackers/src/node/vm-stat.test.ts b/packages/trackers/src/node/vm-stat.test.ts index a0df833bc..2ce939909 100644 --- a/packages/trackers/src/node/vm-stat.test.ts +++ b/packages/trackers/src/node/vm-stat.test.ts @@ -1,12 +1,5 @@ -import { describe, expect, it, vi } from 'vitest'; -import { - createDenoExecFile, - createVmStatSampler, - type DenoRunLike, - denoVmStatGranted, - type ExecFileLike, - parseVmStat, -} from './vm-stat'; +import { describe, expect, it } from 'vitest'; +import { createVmStatSampler, type ExecFileLike, parseVmStat } from './vm-stat'; const OUTPUT = `Mach Virtual Memory Statistics: (page size of 16384 bytes) Pages free: 3000. @@ -372,153 +365,3 @@ describe('createVmStatSampler: cadence, streaks, silent misses', () => { expect(calls).toHaveLength(1); }); }); - -describe('Deno spawn (never prompts)', () => { - const deno = (state: unknown): DenoRunLike & { asked: unknown[] } => { - const asked: unknown[] = []; - return { - asked, - Command: class {} as never, - permissions: { - querySync: (d) => { - asked.push(d); - return { state }; - }, - }, - }; - }; - - it('granted only: queries exactly the run permission for /usr/bin/vm_stat via querySync', () => { - const granted = deno('granted'); - expect(denoVmStatGranted(granted)).toBe(true); - expect(granted.asked).toEqual([{ name: 'run', command: '/usr/bin/vm_stat' }]); - expect(denoVmStatGranted(deno('prompt'))).toBe(false); - expect(denoVmStatGranted(deno('denied'))).toBe(false); - expect(denoVmStatGranted(deno(undefined))).toBe(false); - }); - - it('not granted when Deno, Command, permissions or querySync is missing, or querySync throws', () => { - expect(denoVmStatGranted(undefined)).toBe(false); - expect(denoVmStatGranted({ permissions: { querySync: () => ({ state: 'granted' }) } })).toBe( - false, - ); - expect(denoVmStatGranted({ Command: class {} as never })).toBe(false); - expect(denoVmStatGranted({ Command: class {} as never, permissions: {} })).toBe(false); - expect( - denoVmStatGranted({ - Command: class {} as never, - permissions: { - querySync: () => { - throw new Error('nope'); - }, - }, - }), - ).toBe(false); - }); - - interface Made { - command: string; - options: Record; - } - const fakeCommand = ( - behave: ( - signal: AbortSignal, - ) => Promise<{ success: boolean; code: number; stdout: Uint8Array }>, - ) => { - const made: Made[] = []; - const Command = class { - constructor(command: string, options: Record) { - made.push({ command, options }); - this.options = options; - } - options: Record; - output() { - return behave(this.options.signal as AbortSignal); - } - }; - return { made, deno: { Command } as unknown as DenoRunLike }; - }; - const opts = { timeout: 2000, maxBuffer: 1, encoding: 'utf8' } as const; - - it('runs Deno.Command with clearEnv, no stdin/stderr and the abort signal, and decodes stdout', async () => { - const f = fakeCommand(async () => ({ - success: true, - code: 0, - stdout: new TextEncoder().encode(OUTPUT), - })); - const got = await new Promise<[Error | null, string]>((resolve) => - createDenoExecFile(f.deno)('/usr/bin/vm_stat', [], opts, (e, o) => resolve([e, o])), - ); - expect(got).toEqual([null, OUTPUT]); - expect(f.made[0]?.command).toBe('/usr/bin/vm_stat'); - expect(f.made[0]?.options).toMatchObject({ - args: [], - clearEnv: true, - stdin: 'null', - stdout: 'piped', - stderr: 'null', - }); - }); - - it('a non-zero exit and a rejected spawn become errors; the callback fires once', async () => { - const exit = fakeCommand(async () => ({ success: false, code: 3, stdout: new Uint8Array() })); - const e1 = await new Promise((resolve) => - createDenoExecFile(exit.deno)('/usr/bin/vm_stat', [], opts, (e) => resolve(e)), - ); - expect(e1?.message).toContain('3'); - const rejected = fakeCommand(async () => { - throw new Error('NotCapable'); - }); - const e2 = await new Promise((resolve) => - createDenoExecFile(rejected.deno)('/usr/bin/vm_stat', [], opts, (e) => resolve(e)), - ); - expect(e2?.message).toBe('NotCapable'); - const strange = fakeCommand(async () => Promise.reject('plain')); - const e3 = await new Promise((resolve) => - createDenoExecFile(strange.deno)('/usr/bin/vm_stat', [], opts, (e) => resolve(e)), - ); - expect(e3?.message).toBe('plain'); - }); - - it('clears its timeout once the command settles (no timer left behind)', async () => { - vi.useFakeTimers(); - try { - const f = fakeCommand(async () => ({ success: true, code: 0, stdout: new Uint8Array([65]) })); - let called = false; - createDenoExecFile(f.deno)('/usr/bin/vm_stat', [], opts, () => { - called = true; - }); - await vi.advanceTimersByTimeAsync(0); - expect(called).toBe(true); - expect(vi.getTimerCount()).toBe(0); - } finally { - vi.useRealTimers(); - } - }); - - it('kill() aborts the signal, and the timeout aborts it too', async () => { - const hang = (signal: AbortSignal) => - new Promise((_r, reject) => { - signal.addEventListener('abort', () => reject(new Error('aborted'))); - }); - const a = fakeCommand(hang); - let err: Error | null = null; - const child = createDenoExecFile(a.deno)('/usr/bin/vm_stat', [], opts, (e) => { - err = e; - }); - child.kill(); - await new Promise((r) => setTimeout(r, 5)); - expect((err as Error | null)?.message).toBe('aborted'); - const b = fakeCommand(hang); - const timed = await new Promise((resolve) => - createDenoExecFile(b.deno)('/usr/bin/vm_stat', [], { ...opts, timeout: 5 }, (e) => - resolve(e), - ), - ); - expect(timed?.message).toBe('aborted'); - }); - - it('throws (so the sampler reports a miss) when Deno.Command is absent', () => { - expect(() => createDenoExecFile({})('/x', [], opts, () => {})).toThrow('Deno.Command'); - }); -}); diff --git a/packages/trackers/src/node/vm-stat.ts b/packages/trackers/src/node/vm-stat.ts index fb826ea94..ceaf34222 100644 --- a/packages/trackers/src/node/vm-stat.ts +++ b/packages/trackers/src/node/vm-stat.ts @@ -1,5 +1,5 @@ // macOS "memory available to new work" from `/usr/bin/vm_stat`, for the runtimes that have no native figure -// (Node and Bun; Deno when `systemMemoryInfo` is unavailable). On macOS `os.freemem()` is free pages ONLY (measured +// (Node and Bun). On macOS `os.freemem()` is free pages ONLY (measured // 151-309 MB on a 64 GB Mac while the kernel's available estimate was ~17 GB), so the number is read from the // kernel's own counters instead. It costs a short-lived system process, therefore it is RARE (one read per // `intervalMs`, default 10 s), fully ASYNC, single in-flight and time-boxed (2 s; a HUNG child can therefore delay a @@ -58,7 +58,7 @@ export interface VmStatOptions { now?: () => number; /** Minimum gap between reads (default 10 000 ms). A value is served for at most two intervals. */ intervalMs?: number; - /** Return false to skip spawning (and answer nothing, without an error), e.g. a Deno `run` permission not granted. */ + /** Return false to skip spawning (and answer nothing, without an error) (e.g. a spawn policy that is not granted). */ canSpawn?: () => boolean; /** Receives the first failure of each failure streak. */ onError?: (error: unknown) => void; @@ -154,72 +154,3 @@ export function createVmStatSampler(options: VmStatOptions = {}): VmStatSource { }, }; } - -/** The slice of the Deno namespace the vm_stat spawn needs. */ -export interface DenoRunLike { - Command?: new ( - command: string, - options: { - args: string[]; - clearEnv: boolean; - stdin: 'null'; - stdout: 'piped'; - stderr: 'null'; - signal: AbortSignal; - }, - ) => { output(): Promise<{ success: boolean; code: number; stdout: Uint8Array }> }; - permissions?: { - querySync?: (descriptor: { name: 'run'; command: string }) => { state?: unknown }; - }; -} - -/** - * Is spawning `/usr/bin/vm_stat` already GRANTED on this Deno? `permissions.querySync` never prompts (unlike the - * node:child_process shim, which would show a blocking interactive prompt). Anything else (prompt, denied, API missing, - * a throw) is "not granted": the caller falls back to `Deno.systemMemoryInfo()`. - */ -export function denoVmStatGranted(deno: DenoRunLike | undefined): boolean { - try { - return ( - typeof deno?.Command === 'function' && - deno.permissions?.querySync?.({ name: 'run', command: VM_STAT })?.state === 'granted' - ); - } catch { - return false; - } -} - -/** - * `execFile` over `Deno.Command` (works with only `--allow-run=/usr/bin/vm_stat`; `clearEnv` keeps the spawn from reading - * any environment variable, which would itself need `--allow-env`). Only call after {@link denoVmStatGranted}. - */ -export function createDenoExecFile(deno: DenoRunLike): ExecFileLike { - return (file, args, options, callback) => { - const Command = deno.Command; - if (typeof Command !== 'function') throw new Error('Deno.Command is unavailable'); - const abort = new AbortController(); - const timer = setTimeout(() => abort.abort(), options.timeout); - (timer as { unref?: () => void }).unref?.(); - const finish = (error: Error | null, stdout: string): void => { - clearTimeout(timer); - callback(error, stdout); - }; - new Command(file, { - args: [...args], - clearEnv: true, - stdin: 'null', - stdout: 'piped', - stderr: 'null', - signal: abort.signal, - }) - .output() - .then( - (result) => - result.success - ? finish(null, new TextDecoder().decode(result.stdout)) - : finish(new Error(`vm_stat exited with ${result.code}`), ''), - (error: unknown) => finish(error instanceof Error ? error : new Error(String(error)), ''), - ); - return { kill: () => abort.abort() }; - }; -} diff --git a/packages/util/src/env.test.ts b/packages/util/src/env.test.ts index 1a8628800..1845fad98 100644 --- a/packages/util/src/env.test.ts +++ b/packages/util/src/env.test.ts @@ -3,7 +3,6 @@ import { isBrowser, isBun, isCloudflareWorker, - isDeno, isElectronMain, isElectronRenderer, isNode, @@ -24,24 +23,12 @@ describe('isBun', () => { }); }); -describe('isDeno', () => { - it('is false without a Deno global', () => expect(isDeno()).toBe(false)); - it('is true with a Deno global', () => { - vi.stubGlobal('Deno', {}); - expect(isDeno()).toBe(true); - }); -}); - describe('isNode', () => { it('is true in a Node process (default test env)', () => expect(isNode()).toBe(true)); it('is false when Bun is present', () => { vi.stubGlobal('Bun', {}); expect(isNode()).toBe(false); }); - it('is false when Deno is present', () => { - vi.stubGlobal('Deno', {}); - expect(isNode()).toBe(false); - }); it('is false without a process global', () => { vi.stubGlobal('process', undefined); expect(isNode()).toBe(false); diff --git a/packages/util/src/env.ts b/packages/util/src/env.ts index 25918360b..14ae6ac44 100644 --- a/packages/util/src/env.ts +++ b/packages/util/src/env.ts @@ -4,7 +4,6 @@ interface RuntimeGlobals { Bun?: unknown; - Deno?: unknown; process?: { versions?: { node?: unknown; electron?: unknown }; type?: unknown }; window?: { document?: unknown }; importScripts?: unknown; @@ -17,10 +16,7 @@ const g = globalThis as unknown as RuntimeGlobals; export const isBun = (): boolean => typeof g.Bun !== 'undefined'; -export const isDeno = (): boolean => typeof g.Deno !== 'undefined'; - -export const isNode = (): boolean => - typeof g.process?.versions?.node === 'string' && !isBun() && !isDeno(); +export const isNode = (): boolean => typeof g.process?.versions?.node === 'string' && !isBun(); export const isBrowser = (): boolean => typeof g.window?.document !== 'undefined'; diff --git a/packages/util/src/index.test.ts b/packages/util/src/index.test.ts index 220d9a5ad..8190a24c4 100644 --- a/packages/util/src/index.test.ts +++ b/packages/util/src/index.test.ts @@ -17,7 +17,6 @@ describe('@bugsee/util public surface', () => { 'isBrowser', 'isBun', 'isCloudflareWorker', - 'isDeno', 'isElectronMain', 'isElectronRenderer', 'isNode', diff --git a/packages/util/src/index.ts b/packages/util/src/index.ts index 26c62eabe..e3f32c50f 100644 --- a/packages/util/src/index.ts +++ b/packages/util/src/index.ts @@ -13,7 +13,6 @@ export { isBrowser, isBun, isCloudflareWorker, - isDeno, isElectronMain, isElectronRenderer, isNode, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 14b17c89f..d5442fda1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -110,9 +110,6 @@ importers: '@bugsee/core': specifier: workspace:* version: link:../../packages/core - '@bugsee/deno': - specifier: workspace:* - version: link:../../packages/deno '@bugsee/electron': specifier: workspace:* version: link:../../packages/electron @@ -379,9 +376,6 @@ importers: '@bugsee/core': specifier: workspace:* version: link:../core - '@bugsee/deno': - specifier: workspace:* - version: link:../deno '@bugsee/node': specifier: workspace:* version: link:../node @@ -484,28 +478,6 @@ importers: specifier: workspace:* version: link:../util - packages/deno: - dependencies: - '@bugsee/capture': - specifier: workspace:* - version: link:../capture - '@bugsee/core': - specifier: workspace:* - version: link:../core - '@bugsee/node': - specifier: workspace:* - version: link:../node - '@bugsee/node-utils': - specifier: workspace:* - version: link:../node-utils - devDependencies: - '@bugsee/util': - specifier: workspace:* - version: link:../util - '@types/node': - specifier: ^22.20.5 - version: 22.20.5 - packages/e2e-kit: dependencies: '@bugsee/protocol': @@ -716,9 +688,6 @@ importers: '@bugsee/core': specifier: workspace:* version: link:../core - '@bugsee/deno': - specifier: workspace:* - version: link:../deno '@bugsee/e2e-kit': specifier: workspace:* version: link:../e2e-kit @@ -800,7 +769,7 @@ importers: version: 0.8.3 html-webpack-plugin: specifier: ^5.6.8 - version: 5.6.8(webpack@5.112.2(esbuild@0.28.2)) + version: 5.6.8(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) jsdom: specifier: ^25.0.1 version: 25.0.1 @@ -827,16 +796,16 @@ importers: version: 6.0.3 vite: specifier: ^8.3.5 - version: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(terser@5.51.2)(tsx@4.23.15) + version: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) vue: specifier: ^3.5.0 version: 3.5.44(typescript@6.0.3) webpack: specifier: ^5.112.2 - version: 5.112.2(esbuild@0.28.2) + version: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) webpack-subresource-integrity: specifier: ^5.1.0 - version: 5.1.0(html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)))(webpack@5.112.2(esbuild@0.28.2)) + version: 5.1.0(html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) zone.js: specifier: 0.16.3 version: 0.16.3 @@ -15313,7 +15282,7 @@ snapshots: html-void-elements@3.0.0: {} - html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)): + html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): dependencies: '@types/html-minifier-terser': 6.1.0 html-minifier-terser: 6.1.0 @@ -15321,7 +15290,7 @@ snapshots: pretty-error: 4.0.0 tapable: 2.3.3 optionalDependencies: - webpack: 5.112.2(esbuild@0.28.2) + webpack: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) htmlparser2@6.1.0: dependencies: @@ -16063,15 +16032,16 @@ snapshots: postcss: 8.5.32 optional: true - minimizer-webpack-plugin@5.13.1(esbuild@0.28.2)(webpack@5.112.2(esbuild@0.28.2)): + minimizer-webpack-plugin@5.13.1(esbuild@0.28.2)(postcss@8.5.32)(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): dependencies: '@jridgewell/trace-mapping': 0.3.31 jest-worker: 27.5.1 - schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)) + schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) terser: 5.51.2 - webpack: 5.112.2(esbuild@0.28.2) + webpack: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) optionalDependencies: esbuild: 0.28.2 + postcss: 8.5.32 minipass@7.1.3: {} @@ -17673,14 +17643,14 @@ snapshots: webpack: 5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32) optional: true - schema-utils@4.8.1(webpack@5.112.2(esbuild@0.28.2)): + schema-utils@4.8.1(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): dependencies: '@types/json-schema': 7.0.15 ajv: 8.20.0 ajv-formats: 3.0.1(ajv@8.20.0) ajv-keywords: 5.1.0(ajv@8.20.0) optionalDependencies: - webpack: 5.112.2(esbuild@0.28.2) + webpack: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) scule@1.3.0: {} @@ -18862,20 +18832,6 @@ snapshots: tsx: 4.23.15 yaml: 2.9.1 - vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(terser@5.51.2)(tsx@4.23.15): - dependencies: - lightningcss: 1.33.0 - picomatch: 4.0.7 - postcss: 8.5.32 - rolldown: 1.2.15 - tinyglobby: 0.2.17 - optionalDependencies: - '@types/node': 22.20.5 - esbuild: 0.28.2 - fsevents: 2.3.3 - terser: 5.51.2 - tsx: 4.23.15 - vitefu@1.1.3(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)): optionalDependencies: vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) @@ -19031,16 +18987,16 @@ snapshots: webpack-sources@3.6.0: {} - webpack-subresource-integrity@5.1.0(html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)))(webpack@5.112.2(esbuild@0.28.2)): + webpack-subresource-integrity@5.1.0(html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): dependencies: typed-assert: 1.0.9 - webpack: 5.112.2(esbuild@0.28.2) + webpack: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) optionalDependencies: - html-webpack-plugin: 5.6.8(webpack@5.112.2(esbuild@0.28.2)) + html-webpack-plugin: 5.6.8(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) webpack-virtual-modules@0.6.2: {} - webpack@5.112.2(esbuild@0.28.2): + webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32): dependencies: '@types/estree': 1.0.9 '@types/json-schema': 7.0.15 @@ -19054,8 +19010,8 @@ snapshots: events: 3.3.0 graceful-fs: 4.2.11 mime-db: 1.54.0 - minimizer-webpack-plugin: 5.13.1(esbuild@0.28.2)(webpack@5.112.2(esbuild@0.28.2)) - schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)) + minimizer-webpack-plugin: 5.13.1(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) tapable: 2.3.3 watchpack: 2.6.3 webpack-sources: 3.6.0 @@ -19076,8 +19032,9 @@ snapshots: - sharp - svgo - uglify-js + optional: true - webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32): + webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32): dependencies: '@types/estree': 1.0.9 '@types/json-schema': 7.0.15 @@ -19091,8 +19048,8 @@ snapshots: events: 3.3.0 graceful-fs: 4.2.11 mime-db: 1.54.0 - minimizer-webpack-plugin: 5.13.1(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) - schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + minimizer-webpack-plugin: 5.13.1(esbuild@0.28.2)(postcss@8.5.32)(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) + schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) tapable: 2.3.3 watchpack: 2.6.3 webpack-sources: 3.6.0 @@ -19113,7 +19070,6 @@ snapshots: - sharp - svgo - uglify-js - optional: true whatwg-encoding@3.1.1: dependencies: diff --git a/samples/angular-spa/pnpm-workspace.yaml b/samples/angular-spa/pnpm-workspace.yaml index 983cbab38..27aad0bf1 100644 --- a/samples/angular-spa/pnpm-workspace.yaml +++ b/samples/angular-spa/pnpm-workspace.yaml @@ -22,7 +22,6 @@ overrides: '@bugsee/capture': 'file:../../.local-registry/bugsee-capture.tgz' '@bugsee/cloudflare': 'file:../../.local-registry/bugsee-cloudflare.tgz' '@bugsee/core': 'file:../../.local-registry/bugsee-core.tgz' - '@bugsee/deno': 'file:../../.local-registry/bugsee-deno.tgz' '@bugsee/electron': 'file:../../.local-registry/bugsee-electron.tgz' '@bugsee/elysia': 'file:../../.local-registry/bugsee-elysia.tgz' '@bugsee/express': 'file:../../.local-registry/bugsee-express.tgz' diff --git a/samples/browser-vanilla/pnpm-workspace.yaml b/samples/browser-vanilla/pnpm-workspace.yaml index 880fe1228..4639c31fd 100644 --- a/samples/browser-vanilla/pnpm-workspace.yaml +++ b/samples/browser-vanilla/pnpm-workspace.yaml @@ -17,7 +17,6 @@ overrides: '@bugsee/capture': 'file:../../.local-registry/bugsee-capture.tgz' '@bugsee/cloudflare': 'file:../../.local-registry/bugsee-cloudflare.tgz' '@bugsee/core': 'file:../../.local-registry/bugsee-core.tgz' - '@bugsee/deno': 'file:../../.local-registry/bugsee-deno.tgz' '@bugsee/electron': 'file:../../.local-registry/bugsee-electron.tgz' '@bugsee/elysia': 'file:../../.local-registry/bugsee-elysia.tgz' '@bugsee/express': 'file:../../.local-registry/bugsee-express.tgz' diff --git a/samples/express-api/pnpm-workspace.yaml b/samples/express-api/pnpm-workspace.yaml index 00c22621c..f21d14fe1 100644 --- a/samples/express-api/pnpm-workspace.yaml +++ b/samples/express-api/pnpm-workspace.yaml @@ -17,7 +17,6 @@ overrides: '@bugsee/capture': 'file:../../.local-registry/bugsee-capture.tgz' '@bugsee/cloudflare': 'file:../../.local-registry/bugsee-cloudflare.tgz' '@bugsee/core': 'file:../../.local-registry/bugsee-core.tgz' - '@bugsee/deno': 'file:../../.local-registry/bugsee-deno.tgz' '@bugsee/electron': 'file:../../.local-registry/bugsee-electron.tgz' '@bugsee/elysia': 'file:../../.local-registry/bugsee-elysia.tgz' '@bugsee/express': 'file:../../.local-registry/bugsee-express.tgz' diff --git a/samples/fastify-api/pnpm-workspace.yaml b/samples/fastify-api/pnpm-workspace.yaml index d39800aa1..5a335572e 100644 --- a/samples/fastify-api/pnpm-workspace.yaml +++ b/samples/fastify-api/pnpm-workspace.yaml @@ -19,7 +19,6 @@ overrides: '@bugsee/capture': 'file:../../.local-registry/bugsee-capture.tgz' '@bugsee/cloudflare': 'file:../../.local-registry/bugsee-cloudflare.tgz' '@bugsee/core': 'file:../../.local-registry/bugsee-core.tgz' - '@bugsee/deno': 'file:../../.local-registry/bugsee-deno.tgz' '@bugsee/electron': 'file:../../.local-registry/bugsee-electron.tgz' '@bugsee/elysia': 'file:../../.local-registry/bugsee-elysia.tgz' '@bugsee/express': 'file:../../.local-registry/bugsee-express.tgz' diff --git a/samples/node-service/pnpm-workspace.yaml b/samples/node-service/pnpm-workspace.yaml index 6bd390ba1..b6ca98bec 100644 --- a/samples/node-service/pnpm-workspace.yaml +++ b/samples/node-service/pnpm-workspace.yaml @@ -17,7 +17,6 @@ overrides: '@bugsee/capture': 'file:../../.local-registry/bugsee-capture.tgz' '@bugsee/cloudflare': 'file:../../.local-registry/bugsee-cloudflare.tgz' '@bugsee/core': 'file:../../.local-registry/bugsee-core.tgz' - '@bugsee/deno': 'file:../../.local-registry/bugsee-deno.tgz' '@bugsee/electron': 'file:../../.local-registry/bugsee-electron.tgz' '@bugsee/elysia': 'file:../../.local-registry/bugsee-elysia.tgz' '@bugsee/express': 'file:../../.local-registry/bugsee-express.tgz' diff --git a/samples/node-service/scenarios.md b/samples/node-service/scenarios.md index 27c174612..e89bddd7e 100644 --- a/samples/node-service/scenarios.md +++ b/samples/node-service/scenarios.md @@ -259,7 +259,7 @@ kill-and-restart cycle given the time already spent on the disk-store path. **Un **valid OTLP/JSON**: correct `resourceSpans[].resource.attributes` (including the configured `otelExportResource: {'service.name': 'bugsee-sample-node-service'}` and the required `otelExportHeaders`), correct `scopeSpans[].scope.name` (`com.bugsee.nodejs/performance` — the -node/bun/deno SDK-language token per Profile v1 §4/§5), and well-formed spans (`traceId`/`spanId`/ +node/bun SDK-language token per Profile v1 §4/§5), and well-formed spans (`traceId`/`spanId`/ `startTimeUnixNano`/`endTimeUnixNano`/`attributes`) for both the `app.start` startup transaction and the manual S9 transaction with its 5 child spans. This is entirely independent of F-1 (a completely separate code path from the Bugsee upload) — proof the produce direction works with zero caveats. diff --git a/samples/react-spa/pnpm-workspace.yaml b/samples/react-spa/pnpm-workspace.yaml index c758efb37..b231d30fb 100644 --- a/samples/react-spa/pnpm-workspace.yaml +++ b/samples/react-spa/pnpm-workspace.yaml @@ -17,7 +17,6 @@ overrides: '@bugsee/capture': 'file:../../.local-registry/bugsee-capture.tgz' '@bugsee/cloudflare': 'file:../../.local-registry/bugsee-cloudflare.tgz' '@bugsee/core': 'file:../../.local-registry/bugsee-core.tgz' - '@bugsee/deno': 'file:../../.local-registry/bugsee-deno.tgz' '@bugsee/electron': 'file:../../.local-registry/bugsee-electron.tgz' '@bugsee/elysia': 'file:../../.local-registry/bugsee-elysia.tgz' '@bugsee/express': 'file:../../.local-registry/bugsee-express.tgz' diff --git a/samples/solid-spa/pnpm-workspace.yaml b/samples/solid-spa/pnpm-workspace.yaml index acc4886b4..c8f536faf 100644 --- a/samples/solid-spa/pnpm-workspace.yaml +++ b/samples/solid-spa/pnpm-workspace.yaml @@ -19,7 +19,6 @@ overrides: '@bugsee/capture': 'file:../../.local-registry/bugsee-capture.tgz' '@bugsee/cloudflare': 'file:../../.local-registry/bugsee-cloudflare.tgz' '@bugsee/core': 'file:../../.local-registry/bugsee-core.tgz' - '@bugsee/deno': 'file:../../.local-registry/bugsee-deno.tgz' '@bugsee/electron': 'file:../../.local-registry/bugsee-electron.tgz' '@bugsee/elysia': 'file:../../.local-registry/bugsee-elysia.tgz' '@bugsee/express': 'file:../../.local-registry/bugsee-express.tgz' diff --git a/samples/svelte-spa/pnpm-workspace.yaml b/samples/svelte-spa/pnpm-workspace.yaml index 37107a007..fc41fa410 100644 --- a/samples/svelte-spa/pnpm-workspace.yaml +++ b/samples/svelte-spa/pnpm-workspace.yaml @@ -19,7 +19,6 @@ overrides: '@bugsee/capture': 'file:../../.local-registry/bugsee-capture.tgz' '@bugsee/cloudflare': 'file:../../.local-registry/bugsee-cloudflare.tgz' '@bugsee/core': 'file:../../.local-registry/bugsee-core.tgz' - '@bugsee/deno': 'file:../../.local-registry/bugsee-deno.tgz' '@bugsee/electron': 'file:../../.local-registry/bugsee-electron.tgz' '@bugsee/elysia': 'file:../../.local-registry/bugsee-elysia.tgz' '@bugsee/express': 'file:../../.local-registry/bugsee-express.tgz' diff --git a/samples/vue-spa/pnpm-workspace.yaml b/samples/vue-spa/pnpm-workspace.yaml index 4f9bacfaf..7b46b4635 100644 --- a/samples/vue-spa/pnpm-workspace.yaml +++ b/samples/vue-spa/pnpm-workspace.yaml @@ -17,7 +17,6 @@ overrides: '@bugsee/capture': 'file:../../.local-registry/bugsee-capture.tgz' '@bugsee/cloudflare': 'file:../../.local-registry/bugsee-cloudflare.tgz' '@bugsee/core': 'file:../../.local-registry/bugsee-core.tgz' - '@bugsee/deno': 'file:../../.local-registry/bugsee-deno.tgz' '@bugsee/electron': 'file:../../.local-registry/bugsee-electron.tgz' '@bugsee/elysia': 'file:../../.local-registry/bugsee-elysia.tgz' '@bugsee/express': 'file:../../.local-registry/bugsee-express.tgz' @@ -77,7 +76,6 @@ minimumReleaseAgeExclude: - '@bugsee/capture@0.0.0' - '@bugsee/cloudflare@0.0.0' - '@bugsee/core@0.0.0' - - '@bugsee/deno@0.0.0' - '@bugsee/electron@0.0.0' - '@bugsee/elysia@0.0.0' - '@bugsee/express@0.0.0' diff --git a/samples/webpack-sourcemaps/pnpm-workspace.yaml b/samples/webpack-sourcemaps/pnpm-workspace.yaml index aa5ff07af..381519acb 100644 --- a/samples/webpack-sourcemaps/pnpm-workspace.yaml +++ b/samples/webpack-sourcemaps/pnpm-workspace.yaml @@ -17,7 +17,6 @@ overrides: '@bugsee/capture': 'file:../../.local-registry/bugsee-capture.tgz' '@bugsee/cloudflare': 'file:../../.local-registry/bugsee-cloudflare.tgz' '@bugsee/core': 'file:../../.local-registry/bugsee-core.tgz' - '@bugsee/deno': 'file:../../.local-registry/bugsee-deno.tgz' '@bugsee/electron': 'file:../../.local-registry/bugsee-electron.tgz' '@bugsee/elysia': 'file:../../.local-registry/bugsee-elysia.tgz' '@bugsee/express': 'file:../../.local-registry/bugsee-express.tgz' diff --git a/scripts/ci-local.sh b/scripts/ci-local.sh index 417f22ece..315878eb7 100755 --- a/scripts/ci-local.sh +++ b/scripts/ci-local.sh @@ -2,7 +2,7 @@ # Run the GitHub Actions CI gate locally, step for step. # # pnpm ci:local # the `check` job (lint → typecheck → cycles → coverage → unit) -# pnpm ci:local --e2e # also the `e2e` job (node · bun · deno · real frameworks), ~5 min +# pnpm ci:local --e2e # also the `e2e` job (node · bun · real frameworks), ~5 min # pnpm ci:local --force # ignore the turbo cache, so every package really re-runs # pnpm ci:local --no-install # @@ -83,11 +83,11 @@ step "Test + per-package coverage gate (vitest)" pnpm exec turbo run test:covera step "Harness unit tests (vitest)" pnpm exec turbo run test:unit $FORCE if [ "$RUN_E2E" -eq 1 ]; then - # The harness SKIPS a runtime whose binary is absent, so a missing bun/deno would quietly test + # The harness SKIPS a runtime whose binary is absent, so a missing bun would quietly test # less rather than fail — same reason the workflow verifies the matrix before running. bold "── Verify the runtime matrix is complete" MISSING=0 - for bin in node bun deno; do + for bin in node bun; do if command -v "$bin" >/dev/null 2>&1; then printf ' %-5s %s\n' "$bin" "$("$bin" --version 2>&1 | head -1)" else diff --git a/scripts/test-matrix.sh b/scripts/test-matrix.sh index adb63d681..71f552dd5 100755 --- a/scripts/test-matrix.sh +++ b/scripts/test-matrix.sh @@ -12,7 +12,7 @@ # scripts/test-matrix.sh --full 20 22 24 # ALSO run the full unit suite (pnpm test) on each Node >= 20 # # Complementary gates (run separately): `pnpm test` (full unit suite, host Node) and `pnpm test:e2e` -# (cross-RUNTIME node/bun/deno). This script is the cross-VERSION axis. +# (cross-RUNTIME node/bun). This script is the cross-VERSION axis. set -uo pipefail cd "$(dirname "$0")/.." ROOT="$PWD" @@ -68,5 +68,5 @@ done echo echo "===================== Node-version matrix =====================" printf '%s' "$SUMMARY" -echo "(cross-runtime bun/deno: 'pnpm test:e2e' | full unit suite on host Node: 'pnpm test')" +echo "(cross-runtime node/bun: 'pnpm test:e2e' | full unit suite on host Node: 'pnpm test')" exit "$overall" From f67770536a42e8945df8befb3c890f6b063f72da Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Fri, 6 Nov 2026 17:31:18 +0500 Subject: [PATCH 2/2] fix(review): fail loudly on Deno via the umbrella, scrub changesets and docs, drop canSpawn - umbrella keeps the deno export condition + ./deno subpath as a stub that throws (Deno sets node too; dropping it silently resolved the Node build); restore the umbrella-conditions e2e case and add a unit test - add a drop-deno-support changeset; scrub Deno claims from pending changesets - trackers README: drop Deno clauses; remove canSpawn (Deno-only) and a stray paren - lockfile: only the Deno removals (no unrelated peer-suffix churn) Co-Authored-By: Claude Sonnet 5.5 --- .changeset/app-uptime-context.md | 2 +- .changeset/capture-trace-disk-pressure.md | 2 +- .changeset/delete-legacy-node-samplers.md | 2 +- .changeset/drop-deno-support.md | 7 +++ .changeset/gc-event-and-elu-percent.md | 6 +- .changeset/memory-limit-gate.md | 2 +- .changeset/node-process-tracker.md | 2 +- .changeset/node-runtime-traces.md | 2 +- .changeset/node-storage-tracker.md | 2 +- .changeset/omit-unavailable-elu.md | 5 +- .changeset/ram-system-free-macos-vmstat.md | 2 +- .changeset/ram-system-free-semantics.md | 4 +- CLAUDE.md | 2 +- docs/PROGRESS.md | 2 +- packages/bugsee/package.json | 28 +++++++++ packages/bugsee/src/index.deno.test.ts | 9 +++ packages/bugsee/src/index.deno.ts | 14 +++++ packages/bugsee/tsup.config.ts | 1 + .../test/umbrella-conditions.e2e.ts | 4 +- packages/trackers/README.md | 2 +- packages/trackers/src/node/process-tracker.ts | 2 +- packages/trackers/src/node/vm-stat.test.ts | 21 ------- packages/trackers/src/node/vm-stat.ts | 8 +-- pnpm-lock.yaml | 57 ++++++++++++------- 24 files changed, 117 insertions(+), 71 deletions(-) create mode 100644 .changeset/drop-deno-support.md create mode 100644 packages/bugsee/src/index.deno.test.ts create mode 100644 packages/bugsee/src/index.deno.ts diff --git a/.changeset/app-uptime-context.md b/.changeset/app-uptime-context.md index bbe6e5c84..d8788416e 100644 --- a/.changeset/app-uptime-context.md +++ b/.changeset/app-uptime-context.md @@ -4,4 +4,4 @@ '@bugsee/trackers': minor --- -`environment.app.uptime_s` (whole seconds the process, or for the browser the document, had been running when the capture session started) is now written once at launch on Node, Bun, Deno, Electron main and the browser. It replaces the per-second `process_uptime_s` system trace, which is retired together with the node `ProcessTracker` `uptime` stage. +`environment.app.uptime_s` (whole seconds the process, or for the browser the document, had been running when the capture session started) is now written once at launch on Node, Bun, Electron main and the browser. It replaces the per-second `process_uptime_s` system trace, which is retired together with the node `ProcessTracker` `uptime` stage. diff --git a/.changeset/capture-trace-disk-pressure.md b/.changeset/capture-trace-disk-pressure.md index 637a27eff..02647827f 100644 --- a/.changeset/capture-trace-disk-pressure.md +++ b/.changeset/capture-trace-disk-pressure.md @@ -11,4 +11,4 @@ '@bugsee/electron': minor --- -Disk-pressure protection for the capture stores, on by default where a durable store exists (as on iOS), and a new `capture` system trace. Below 50 MiB free the on-disk (Node, Bun, Deno, Electron main: `statfs` of the data directory every 5 s) or IndexedDB (browser: `navigator.storage.estimate()` headroom, every 5 minutes, every 30 s under 500 MiB) store stops persisting replay, log and network data; below 10 MiB it persists nothing, except the tiny `capture` state record while the state comes from a free-space reading (not while a refused write pins it). The in-memory window is kept either way, so a report built from the live process holds everything the process still has in memory (records waiting for a file that could not be created yet included; with the opt-in worker ring writer, frames still stuck in the ring while the disk is full are not in it) and only a crash loses what was never written (records already on a medium that can no longer be read are not in that report, which is built and delivered anyway). A state is left only 10 MiB above its threshold; a hostile or missing reading never changes the state; a write failing with `QuotaExceededError` / `ENOSPC` (and, for an IndexedDB write, Chromium's `AbortError` / `InvalidStateError`) pins out-of-space until a durable DATA write succeeds again (not until a size reading looks healthy; the probe is a record-sized data write forced past the writer's circuit breaker and backs off so the state cannot flap, and capture resumes within a minute of the disk being freed). `diskProtection: false` opts out. The opt-in `captureDiskSpace` option (canonical key `com.bugsee.option.capture.disk-space`, now shared by the browser and the Node family; the node-only key is gone, the friendly name is unchanged) is only the telemetry: the `capture` trace's `low_disk_space` / `no_disk_space` states and, on Node, `disk_mem_free` / `disk_mem_total`. The `capture` trace (`{state}`: `active`, `blackout`, `low_disk_space`, `no_disk_space`) is written by the browser while its rrweb recorder runs and by Electron main while pixel video runs; never by Node, Bun, Deno, WebViews, Electron renderers or a launch with `replay: false`. Fixes in the batched fs writer: `read()` includes the buffered tail of a failed flush and a chunk seal no longer drops it; the off-thread ring writer reports drain failures instead of swallowing them; a `statfs` that hangs holds one read and starts no more; a durable snapshot or drain that throws synchronously, or a read that overruns, never fails a report (the in-memory records are served, once-per-streak report, and a slow healthy read ends the degraded state); the batched writer decodes `read()` once across the disk/tail boundary and keeps records of a file it cannot create yet; a short write followed by a failure no longer duplicates data in the ring writer; the IndexedDB store keeps records not yet written (queued or refused) in memory and serves them when the database cannot be read, reopens a closed connection, and times out and releases a read that never answers; the disk-pressure probe is a synchronous write of padding into a file of its own in the part just opened (never queued as a ring frame, never a part of its own), so it leaves no directory, descriptor or late write behind, and a host-side failure of the ring writer can be recovered from. `@bugsee/replay` recorders gain `checkout()` (a fresh full snapshot, used when persistence resumes). New `@bugsee/core` exports: `createDiskPressure`, `withDiskPressure`, `DiskPressureToken`, `isOutOfSpaceError`, the threshold constants, and `diskPressure` / `onDiskWriteError` options on the chunk, file and IndexedDB stores. +Disk-pressure protection for the capture stores, on by default where a durable store exists (as on iOS), and a new `capture` system trace. Below 50 MiB free the on-disk (Node, Bun, Electron main: `statfs` of the data directory every 5 s) or IndexedDB (browser: `navigator.storage.estimate()` headroom, every 5 minutes, every 30 s under 500 MiB) store stops persisting replay, log and network data; below 10 MiB it persists nothing, except the tiny `capture` state record while the state comes from a free-space reading (not while a refused write pins it). The in-memory window is kept either way, so a report built from the live process holds everything the process still has in memory (records waiting for a file that could not be created yet included; with the opt-in worker ring writer, frames still stuck in the ring while the disk is full are not in it) and only a crash loses what was never written (records already on a medium that can no longer be read are not in that report, which is built and delivered anyway). A state is left only 10 MiB above its threshold; a hostile or missing reading never changes the state; a write failing with `QuotaExceededError` / `ENOSPC` (and, for an IndexedDB write, Chromium's `AbortError` / `InvalidStateError`) pins out-of-space until a durable DATA write succeeds again (not until a size reading looks healthy; the probe is a record-sized data write forced past the writer's circuit breaker and backs off so the state cannot flap, and capture resumes within a minute of the disk being freed). `diskProtection: false` opts out. The opt-in `captureDiskSpace` option (canonical key `com.bugsee.option.capture.disk-space`, now shared by the browser and the Node family; the node-only key is gone, the friendly name is unchanged) is only the telemetry: the `capture` trace's `low_disk_space` / `no_disk_space` states and, on Node, `disk_mem_free` / `disk_mem_total`. The `capture` trace (`{state}`: `active`, `blackout`, `low_disk_space`, `no_disk_space`) is written by the browser while its rrweb recorder runs and by Electron main while pixel video runs; never by Node, Bun, WebViews, Electron renderers or a launch with `replay: false`. Fixes in the batched fs writer: `read()` includes the buffered tail of a failed flush and a chunk seal no longer drops it; the off-thread ring writer reports drain failures instead of swallowing them; a `statfs` that hangs holds one read and starts no more; a durable snapshot or drain that throws synchronously, or a read that overruns, never fails a report (the in-memory records are served, once-per-streak report, and a slow healthy read ends the degraded state); the batched writer decodes `read()` once across the disk/tail boundary and keeps records of a file it cannot create yet; a short write followed by a failure no longer duplicates data in the ring writer; the IndexedDB store keeps records not yet written (queued or refused) in memory and serves them when the database cannot be read, reopens a closed connection, and times out and releases a read that never answers; the disk-pressure probe is a synchronous write of padding into a file of its own in the part just opened (never queued as a ring frame, never a part of its own), so it leaves no directory, descriptor or late write behind, and a host-side failure of the ring writer can be recovered from. `@bugsee/replay` recorders gain `checkout()` (a fresh full snapshot, used when persistence resumes). New `@bugsee/core` exports: `createDiskPressure`, `withDiskPressure`, `DiskPressureToken`, `isOutOfSpaceError`, the threshold constants, and `diskPressure` / `onDiskWriteError` options on the chunk, file and IndexedDB stores. diff --git a/.changeset/delete-legacy-node-samplers.md b/.changeset/delete-legacy-node-samplers.md index 41e4c7e45..5cc8eaa04 100644 --- a/.changeset/delete-legacy-node-samplers.md +++ b/.changeset/delete-legacy-node-samplers.md @@ -3,4 +3,4 @@ '@bugsee/bun': minor --- -Removed the legacy `createNodeSystemMetricsSampler` and `createGuardedSystemMetricsSampler` (and their `NodeSystemMetricsDeps` / `GuardedSystemMetricsDeps` types). Nothing in the SDK used them; node, Bun and Deno already build their system traces from `createNodeSystemTraceProducers`. A caller-supplied `systemMetricsSampler` option still works, and `PerfHooks` is still exported. +Removed the legacy `createNodeSystemMetricsSampler` and `createGuardedSystemMetricsSampler` (and their `NodeSystemMetricsDeps` / `GuardedSystemMetricsDeps` types). Nothing in the SDK used them; node and Bun already build their system traces from `createNodeSystemTraceProducers`. A caller-supplied `systemMetricsSampler` option still works, and `PerfHooks` is still exported. diff --git a/.changeset/drop-deno-support.md b/.changeset/drop-deno-support.md new file mode 100644 index 000000000..e6c78312f --- /dev/null +++ b/.changeset/drop-deno-support.md @@ -0,0 +1,7 @@ +--- +'@bugsee/bugsee': minor +'@bugsee/util': minor +'@bugsee/trackers': minor +--- + +**Deno is no longer supported.** `@bugsee/deno` is removed (deprecate the published versions on npm; use Node.js, Bun or a browser). The `@bugsee/bugsee` umbrella keeps its `deno` export condition and `./deno` subpath only so that importing it on Deno throws a clear "Deno is no longer supported" error instead of silently resolving the Node build, which misreports the runtime, leaves `Deno.serve` uninstrumented and can freeze the process when local-variable capture is on. `isDeno` is removed from `@bugsee/util` (`isNode()` no longer excludes Deno). `@bugsee/trackers/node` no longer exports `createDenoMemoryReader`, `createDenoExecFile` or `denoVmStatGranted`, and `createVmStatSampler` no longer accepts `canSpawn` (it existed only for Deno's `run` permission). The protocol `RuntimeType` still includes `'deno'` so existing reports stay valid. diff --git a/.changeset/gc-event-and-elu-percent.md b/.changeset/gc-event-and-elu-percent.md index 33da2b9c8..bd19f25cc 100644 --- a/.changeset/gc-event-and-elu-percent.md +++ b/.changeset/gc-event-and-elu-percent.md @@ -7,7 +7,7 @@ System traces are unified with Android/iOS (C15, C16). None of this has been released before, so there is no migration. -- `event_loop_utilization` is a PERCENT 0-100 with one decimal (`60` is "60% busy"), consistent with `cpu_usage_process`, not a `0..1` fraction. Bun and Deno still omit it (their `eventLoopUtilization()` answers flat zeros). The ProcessTracker `utilization` stage payload is now `{ utilizationPercent }` instead of `{ utilization }`, and an injected `eventLoopUtilization` reader must answer percent. +- `event_loop_utilization` is a PERCENT 0-100 with one decimal (`60` is "60% busy"), consistent with `cpu_usage_process`, not a `0..1` fraction. Bun still omits it (its `eventLoopUtilization()` answers flat zeros). The ProcessTracker `utilization` stage payload is now `{ utilizationPercent }` instead of `{ utilization }`, and an injected `eventLoopUtilization` reader must answer percent. - **No gc traces:** `gc_count`, `gc_pause_ms` and `gc_pause_max_ms` are not written to `traces.system`. -- **New event:** garbage collection is the `gc` event in `events.system`, params `{ count, pauseMs, maxPauseMs }` (pauses rounded to 3 decimals). One event is written per 1 s interval in which at least one collection ran; a quiet interval writes nothing. Node and Electron main only: Bun and Deno never emit it (their GC observer is blind). The observer exists only while system events are captured (`captureSystemEvents`). `createNodeSystemEventsSource` gains `processTracker` and `onError` options. -- **Timers:** the GC observer and its share of the 1 s tracker sampling timer now belong to system events, so `captureSystemTraces: false` alone no longer means no sampling timer on Node (set `captureSystemEvents: false` too). A tracker stage the runtime can never answer (Bun/Deno gates) no longer keeps that timer alive. +- **New event:** garbage collection is the `gc` event in `events.system`, params `{ count, pauseMs, maxPauseMs }` (pauses rounded to 3 decimals). One event is written per 1 s interval in which at least one collection ran; a quiet interval writes nothing. Node and Electron main only: Bun never emits it (its GC observer is blind). The observer exists only while system events are captured (`captureSystemEvents`). `createNodeSystemEventsSource` gains `processTracker` and `onError` options. +- **Timers:** the GC observer and its share of the 1 s tracker sampling timer now belong to system events, so `captureSystemTraces: false` alone no longer means no sampling timer on Node (set `captureSystemEvents: false` too). A tracker stage the runtime can never answer (Bun gates) no longer keeps that timer alive. diff --git a/.changeset/memory-limit-gate.md b/.changeset/memory-limit-gate.md index ee29f2116..1d2730a9a 100644 --- a/.changeset/memory-limit-gate.md +++ b/.changeset/memory-limit-gate.md @@ -4,4 +4,4 @@ '@bugsee/bun': minor --- -`process_memory_limit` now has an explicit runtime gate, `measuresConstrainedMemory` (default on). Bun and Deno enable it only on Linux, the one platform where a cgroup cap exists, so the trace is omitted elsewhere instead of relying on the value filter alone. +`process_memory_limit` now has an explicit runtime gate, `measuresConstrainedMemory` (default on). Bun enables it only on Linux, the one platform where a cgroup cap exists, so the trace is omitted elsewhere instead of relying on the value filter alone. diff --git a/.changeset/node-process-tracker.md b/.changeset/node-process-tracker.md index c0194546a..a58fc9517 100644 --- a/.changeset/node-process-tracker.md +++ b/.changeset/node-process-tracker.md @@ -4,4 +4,4 @@ '@bugsee/trackers': minor --- -Node and Bun system traces now come from a per-process `ProcessTracker` in the new `@bugsee/trackers/node` entry, which replaces `@bugsee/node`'s `ProcessStatsTracker`. Trace names are unchanged, the GC observer and event-loop histogram now run only while their traces are enabled, and the runtime gates for Bun and Deno still omit the traces those runtimes cannot measure honestly. The `cpu_usage_*` traces no longer record a start value (it was a microsecond-window noise reading); they begin with the first sample. `@bugsee/node` (and so `@bugsee/bun` and `@bugsee/deno`, which re-export it) no longer exports `ProcessStatsTracker` and `ProcessStats`; it exports `processTrackerFor`, `resetProcessTracker` and the `ProcessTracker` type instead. +Node and Bun system traces now come from a per-process `ProcessTracker` in the new `@bugsee/trackers/node` entry, which replaces `@bugsee/node`'s `ProcessStatsTracker`. Trace names are unchanged, the GC observer and event-loop histogram now run only while their traces are enabled, and the runtime gates for Bun still omit the traces those runtimes cannot measure honestly. The `cpu_usage_*` traces no longer record a start value (it was a microsecond-window noise reading); they begin with the first sample. `@bugsee/node` (and so `@bugsee/bun`, which re-exports it) no longer exports `ProcessStatsTracker` and `ProcessStats`; it exports `processTrackerFor`, `resetProcessTracker` and the `ProcessTracker` type instead. diff --git a/.changeset/node-runtime-traces.md b/.changeset/node-runtime-traces.md index 2859dcaab..72ad70e8e 100644 --- a/.changeset/node-runtime-traces.md +++ b/.changeset/node-runtime-traces.md @@ -5,7 +5,7 @@ Node and Bun now report more runtime traces in `traces.system`: -- `v8_heap_size_limit`, `v8_heap_available`, `v8_heap_malloced`, `v8_heap_peak_malloced` and the ceiling-based `ram_js_heap_total` / `_used` / `_free` (`total` is the heap limit, not the committed heap). Node and Deno only; omitted on Bun, whose heap statistics are not a V8 ceiling. +- `v8_heap_size_limit`, `v8_heap_available`, `v8_heap_malloced`, `v8_heap_peak_malloced` and the ceiling-based `ram_js_heap_total` / `_used` / `_free` (`total` is the heap limit, not the committed heap). Node only; omitted on Bun, whose heap statistics are not a V8 ceiling. - `process_memory_limit` (the cgroup cap), reported only for a real cap: omitted when `process.constrainedMemory()` is 0, the 2^64 sentinel, or at least total RAM. `createNodeSystemTraceProducers` gains `measuresV8Heap` (default `true`) for runtimes that cannot answer honestly. diff --git a/.changeset/node-storage-tracker.md b/.changeset/node-storage-tracker.md index 58af85f74..510a8d8ff 100644 --- a/.changeset/node-storage-tracker.md +++ b/.changeset/node-storage-tracker.md @@ -4,4 +4,4 @@ '@bugsee/trackers': minor --- -The opt-in `captureDiskSpace` traces (`disk_mem_free`, `disk_mem_total`) now come from a per-process `StorageTracker` in the `@bugsee/trackers/node` entry, which takes over the statfs read and its poll from `@bugsee/node`. Trace names, integer-MB wire values, the 5 s cadence and the opt-in behaviour are unchanged: the tracker polls only while the producer is subscribed, reports a failing read once per failure streak, and omits an unreadable or unsane reading instead of reporting a zero. The tracker is shared per data directory: launches over the same directory share one (its `onError` and scheduler are latest-launch-wins), launches over different directories each keep polling their own directory and reporting to their own `onError`. `@bugsee/node` (and so `@bugsee/bun` and `@bugsee/deno`, which re-export it) also exports `storageTrackerFor`, `resetStorageTracker` and the `StorageTracker` type. +The opt-in `captureDiskSpace` traces (`disk_mem_free`, `disk_mem_total`) now come from a per-process `StorageTracker` in the `@bugsee/trackers/node` entry, which takes over the statfs read and its poll from `@bugsee/node`. Trace names, integer-MB wire values, the 5 s cadence and the opt-in behaviour are unchanged: the tracker polls only while the producer is subscribed, reports a failing read once per failure streak, and omits an unreadable or unsane reading instead of reporting a zero. The tracker is shared per data directory: launches over the same directory share one (its `onError` and scheduler are latest-launch-wins), launches over different directories each keep polling their own directory and reporting to their own `onError`. `@bugsee/node` (and so `@bugsee/bun`, which re-exports it) also exports `storageTrackerFor`, `resetStorageTracker` and the `StorageTracker` type. diff --git a/.changeset/omit-unavailable-elu.md b/.changeset/omit-unavailable-elu.md index 42a82554d..320ebe9d6 100644 --- a/.changeset/omit-unavailable-elu.md +++ b/.changeset/omit-unavailable-elu.md @@ -4,7 +4,7 @@ Event-loop utilization is now omitted on runtimes that cannot measure it, instead of reported as 0%. -`performance.eventLoopUtilization()` exists on Bun and Deno and does not throw — it simply answers +`performance.eventLoopUtilization()` exists on Bun and does not throw — it simply answers `{idle: 0, active: 0, utilization: 0}` for ever. The SDK's guard only caught *throws*, so every sample carried a confident 0%, which reads exactly like a perfectly healthy idle process to whoever opens the report. Measured after a 120 ms CPU burn plus a 60 ms sleep: @@ -12,10 +12,9 @@ report. Measured after a 120 ms CPU burn plus a 60 ms sleep: ``` node {"idle":61.0,"active":0.118,"utilization":0.0019} bun {"idle":0,"active":0,"utilization":0} -deno {"idle":0,"active":0,"utilization":0} ``` -The `event_loop_utilization` trace is now absent on Bun and Deno and unchanged on Node. The +The `event_loop_utilization` trace is now absent on Bun and unchanged on Node. The discriminator is `idle`, not `utilization`: idle accumulates wall-clock time between samples on any honest implementation, so it cannot be zero at the sampler's 1 s cadence — while a process that genuinely did nothing reports utilization 0 with a non-zero idle, and that reading is true and kept. diff --git a/.changeset/ram-system-free-macos-vmstat.md b/.changeset/ram-system-free-macos-vmstat.md index a282028f9..50e9451ef 100644 --- a/.changeset/ram-system-free-macos-vmstat.md +++ b/.changeset/ram-system-free-macos-vmstat.md @@ -4,4 +4,4 @@ '@bugsee/bun': minor --- -`ram_system_free` is now reported on macOS for Node and Bun and Deno. It reads `/usr/bin/vm_stat` asynchronously at most once per 10 seconds, and only while the system-memory stage has a listener. The value is (Pages free + File-backed pages + Pages purgeable) times the page size, the same definition as Electron's `getSystemMemoryInfo` on macOS, so Electron, Node and Bun agree. The spawn uses the absolute path with no shell or arguments, a 2 s timeout and a small output cap. It never overlaps, serves a value for at most two intervals before omitting, and any failure omits the trace and is reported once per failure streak through `onError`. The child is killed when the stage loses its last listener, and an empty read caused by a resumed `execFile` timeout is a silent miss. On Deno the spawn goes through `Deno.Command` (works with only `--allow-run=/usr/bin/vm_stat`, never prompts) and happens only when `Deno.permissions.querySync` already reports it granted; otherwise Deno answers `Deno.systemMemoryInfo().available`, a larger estimate (free + inactive pages) than the vm_stat definition. `current()` on an unarmed stage reads the cache only and never spawns. `@bugsee/trackers/node` gains `createVmStatSampler` and `parseVmStat`, and `ProcessEnv` gains `readsVmStat` (default `true`; `false` opts out), `vmStat` and `vmStatExecFile`, and `@bugsee/trackers/node` also exports `createDenoExecFile` and `denoVmStatGranted`. To opt out, pass `systemTraceProducers: createNodeSystemTraceProducers({ readsVmStat: false })` to `launch`. +`ram_system_free` is now reported on macOS for Node and Bun. It reads `/usr/bin/vm_stat` asynchronously at most once per 10 seconds, and only while the system-memory stage has a listener. The value is (Pages free + File-backed pages + Pages purgeable) times the page size, the same definition as Electron's `getSystemMemoryInfo` on macOS, so Electron, Node and Bun agree. The spawn uses the absolute path with no shell or arguments, a 2 s timeout and a small output cap. It never overlaps, serves a value for at most two intervals before omitting, and any failure omits the trace and is reported once per failure streak through `onError`. The child is killed when the stage loses its last listener, and an empty read caused by a resumed `execFile` timeout is a silent miss. `current()` on an unarmed stage reads the cache only and never spawns. `@bugsee/trackers/node` gains `createVmStatSampler` and `parseVmStat`, and `ProcessEnv` gains `readsVmStat` (default `true`; `false` opts out), `vmStat` and `vmStatExecFile`. To opt out, pass `systemTraceProducers: createNodeSystemTraceProducers({ readsVmStat: false })` to `launch`. diff --git a/.changeset/ram-system-free-semantics.md b/.changeset/ram-system-free-semantics.md index 07e1303c3..918d9b5ed 100644 --- a/.changeset/ram-system-free-semantics.md +++ b/.changeset/ram-system-free-semantics.md @@ -5,6 +5,6 @@ '@bugsee/trackers': minor --- -`ram_system_free` now means memory available to new work, in bytes as on Android (`availMem`), instead of raw free pages. Sources: Electron `process.getSystemMemoryInfo()` (macOS free + fileBacked + purgeable, Linux `available`, Windows `free`), Deno `systemMemoryInfo().available` on macOS, `/proc/meminfo` `MemAvailable` on Bun, then `os.freemem()` (libuv `MemAvailable` on Linux, `ullAvailPhys` on Windows). Node and Bun on macOS read it from a rare async `vm_stat` call (see the vm_stat changeset), because `os.freemem()` there is free pages only. The value is omitted when no source gives a finite, non-negative number not above total RAM. Inside a container it is the host's figure; the cap is `process_memory_limit`. +`ram_system_free` now means memory available to new work, in bytes as on Android (`availMem`), instead of raw free pages. Sources: Electron `process.getSystemMemoryInfo()` (macOS free + fileBacked + purgeable, Linux `available`, Windows `free`), `/proc/meminfo` `MemAvailable` on Bun, then `os.freemem()` (libuv `MemAvailable` on Linux, `ullAvailPhys` on Windows). Node and Bun on macOS read it from a rare async `vm_stat` call (see the vm_stat changeset), because `os.freemem()` there is free pages only. The value is omitted when no source gives a finite, non-negative number not above total RAM. Inside a container it is the host's figure; the cap is `process_memory_limit`. -The `ram_system_available` trace is removed (it was Node-only and never released): `process.availableMemory()` equals `os.freemem()` without a cgroup limit and reads lower inside one, and it is not comparable on Bun and Deno. `@bugsee/trackers/node` drops the `availableMemory` stage and `createAvailableMemoryReader`, and gains `createProcMeminfoReader` and `parseMemAvailable`. The `measuresAvailableMemory` option is replaced by `readsProcMeminfo` (default `false`; only Bun sets it), and `createSystemFreeReader`, `createElectronMemoryReader`, `createDenoMemoryReader` and `firstAnswer` are exported. +The `ram_system_available` trace is removed (it was Node-only and never released): `process.availableMemory()` equals `os.freemem()` without a cgroup limit and reads lower inside one, and it is not comparable on Bun. `@bugsee/trackers/node` drops the `availableMemory` stage and `createAvailableMemoryReader`, and gains `createProcMeminfoReader` and `parseMemAvailable`. The `measuresAvailableMemory` option is replaced by `readsProcMeminfo` (default `false`; only Bun sets it), and `createSystemFreeReader`, `createElectronMemoryReader` and `firstAnswer` are exported. diff --git a/CLAUDE.md b/CLAUDE.md index 6e6878470..c0f47b62d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -19,7 +19,7 @@ Runnable SDKs exist for **Node, Browser, Bun, Electron, Cloudflare/Vercel edge, - Shared capture: `@bugsee/capture` (console→log; fetch/xhr/ws/sse/webtransport → network umbrella; system traces/events providers). - Node platform: `@bugsee/node-utils` (httpRequest transport, fs storage + bundle store) and `@bugsee/node` (`launch()`, node:http interceptor, env builder, detection providers, system metrics). Plus opt-in **node diagnostics**: rolling V8 CPU profiling (`profile.json`) + ANR/event-loop-hang detection (worker-thread watchdog → `AppHang` reports). Plus **multi-instance on-disk coexistence** (`docs/design/multi-instance-disk-coexistence.md`): several aggregators (worker_threads / processes) safely share one `dataDir` — each writes a per-instance subtree `/--/` (+ `owner.json` + `.live` heartbeat); on launch a coordinator opportunistically recovers DEAD sibling subtrees (Android-canonical), gated by a portable liveness check (`process.kill(pid,0)` + heartbeat staleness — the native-free replacement for Java's `FileLock`). - Browser platform: `@bugsee/browser-utils` (fetch transport, IndexedDB storage + bundle store) and `@bugsee/browser` (`launch()`, global error/network capture, IndexedDB-persisted capture). -- Bun platform: `@bugsee/bun` — re-exports the `@bugsee/node` composition and overrides only the runtime identity probe (+ a shared guarded `perf_hooks` sampler); **full Node feature parity incl. profiling + ANR**. Bun-specific gates (measured): `performance.eventLoopUtilization()` answers flat zeros, so the ELU trace is OMITTED rather than reported as 0% (discriminated on `idle`, which accumulates on any honest implementation); `captureLocalVariables` is hard-gated OFF in `@bugsee/bun/src/launch.ts` AFTER `...options` (`Debugger.enable` is refused without an active inspector, so the feature would be silently inert). **Deno support was DROPPED (2026-11-06, owner decision)** — `@bugsee/deno`, its umbrella `deno` entry/condition, e2e target, CI job and the Deno-only tracker code (`createDenoMemoryReader`, `Deno.Command` vm_stat spawn, `isDeno`) are removed; the protocol's `'deno'` runtime-type enum value is KEPT (backend wire contract). Generic seams introduced for it (`measuresEventLoopDelay`, `measuresGc`, …) remain as launch options. Historical Deno analysis lives only in `docs/review/` and `docs/research/`. +- Bun platform: `@bugsee/bun` — re-exports the `@bugsee/node` composition and overrides only the runtime identity probe (+ a shared guarded `perf_hooks` sampler); **full Node feature parity incl. profiling + ANR**. Bun-specific gates (measured): `performance.eventLoopUtilization()` answers flat zeros, so the ELU trace is OMITTED rather than reported as 0% (discriminated on `idle`, which accumulates on any honest implementation); `captureLocalVariables` is hard-gated OFF in `@bugsee/bun/src/launch.ts` AFTER `...options` (`Debugger.enable` is refused without an active inspector, so the feature would be silently inert). **Deno support was DROPPED (2026-11-06, owner decision)** — `@bugsee/deno`, e2e target, CI job and the Deno-only tracker code (`createDenoMemoryReader`, `Deno.Command` vm_stat spawn, `isDeno`) are removed. The umbrella KEEPS a `deno` export condition + `./deno` subpath whose module only THROWS "Deno is no longer supported" (Deno sets `node` too, so dropping the condition would silently resolve the Node build); the protocol's `'deno'` runtime-type enum value is KEPT (backend wire contract). Generic seams introduced for it (`measuresEventLoopDelay`, `measuresGc`, …) remain as launch options. Historical Deno analysis lives only in `docs/review/` and `docs/research/`. - 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`). diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 79b7fb35e..ffe4b9bda 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -1312,7 +1312,7 @@ recorded" was false. ### 2026-11-06 — Deno support dropped (owner decision) -Removed `@bugsee/deno` and everything that existed only for it: the umbrella `deno` entry + `exports` condition + `./deno` subpath, the `deno` e2e target and `entry-deno.ts`, the `Deno.serve` branch of the native-server scenario, the CI `Setup Deno` step and `deno --version` check, the `isDeno` util, the Deno-only tracker code (`createDenoMemoryReader`, `createDenoExecFile`/`denoVmStatGranted`, the `Deno.Command` vm_stat spawn) with their tests, sample `pnpm-workspace` overrides, and the `@bugsee/deno` lines in pending changesets (plus the Deno-only `omit-unmeasurable-event-loop-lag` changeset). KEPT on purpose: the protocol `RuntimeType` `'deno'` value (backend wire contract; historical data) and the generic launch seams (`measuresEventLoopDelay`, `measuresGc`, …). `docs/review/`, `docs/research/` and the older design docs still describe Deno as it was; they are history, not as-built. Entries below that mention Deno are superseded by this one. +Removed `@bugsee/deno` and everything that existed only for it: the umbrella's working `deno` entry (the `deno` condition + `./deno` subpath are KEPT as a stub that throws "Deno is no longer supported", because Deno also sets `node` and would otherwise silently resolve the Node build), the `deno` e2e target and `entry-deno.ts`, the `Deno.serve` branch of the native-server scenario, the CI `Setup Deno` step and `deno --version` check, the `isDeno` util, the Deno-only tracker code (`createDenoMemoryReader`, `createDenoExecFile`/`denoVmStatGranted`, the `Deno.Command` vm_stat spawn) with their tests, sample `pnpm-workspace` overrides, and the `@bugsee/deno` lines in pending changesets (plus the Deno-only `omit-unmeasurable-event-loop-lag` changeset). KEPT on purpose: the protocol `RuntimeType` `'deno'` value (backend wire contract; historical data) and the generic launch seams (`measuresEventLoopDelay`, `measuresGc`, …). `docs/review/`, `docs/research/` and the older design docs still describe Deno as it was; they are history, not as-built. Entries below that mention Deno are superseded by this one. ### 2026-10-27 — Spec-conformance guard for the system traces and events (spec items C17 + C24) diff --git a/packages/bugsee/package.json b/packages/bugsee/package.json index 1a78ddfb5..095e4900c 100644 --- a/packages/bugsee/package.json +++ b/packages/bugsee/package.json @@ -25,6 +25,10 @@ "types": "./src/index.bun.ts", "import": "./src/index.bun.ts" }, + "deno": { + "types": "./src/index.deno.ts", + "import": "./src/index.deno.ts" + }, "worker": { "types": "./src/index.worker.ts", "import": "./src/index.worker.ts" @@ -50,6 +54,10 @@ "types": "./src/index.bun.ts", "import": "./src/index.bun.ts" }, + "./deno": { + "types": "./src/index.deno.ts", + "import": "./src/index.deno.ts" + }, "./workerd": { "types": "./src/index.workerd.ts", "import": "./src/index.workerd.ts" @@ -109,6 +117,16 @@ "default": "./dist/index.bun.cjs" } }, + "deno": { + "import": { + "types": "./dist/index.deno.d.ts", + "default": "./dist/index.deno.js" + }, + "require": { + "types": "./dist/index.deno.d.cts", + "default": "./dist/index.deno.cjs" + } + }, "worker": { "import": { "types": "./dist/index.worker.d.ts", @@ -170,6 +188,16 @@ "default": "./dist/index.bun.cjs" } }, + "./deno": { + "import": { + "types": "./dist/index.deno.d.ts", + "default": "./dist/index.deno.js" + }, + "require": { + "types": "./dist/index.deno.d.cts", + "default": "./dist/index.deno.cjs" + } + }, "./workerd": { "import": { "types": "./dist/index.workerd.d.ts", diff --git a/packages/bugsee/src/index.deno.test.ts b/packages/bugsee/src/index.deno.test.ts new file mode 100644 index 000000000..9d8f45b66 --- /dev/null +++ b/packages/bugsee/src/index.deno.test.ts @@ -0,0 +1,9 @@ +import { describe, expect, it } from 'vitest'; + +// The umbrella's `deno` export condition exists only to fail loudly. Deno sets `node` too, so without this +// entry it would silently resolve the node build (wrong runtime identity, uninstrumented `Deno.serve`). +describe('the unsupported Deno entry', () => { + it('throws a clear error on import instead of exposing a launch()', async () => { + await expect(import('./index.deno')).rejects.toThrow(/Deno is no longer supported/); + }); +}); diff --git a/packages/bugsee/src/index.deno.ts b/packages/bugsee/src/index.deno.ts new file mode 100644 index 000000000..c7a09720b --- /dev/null +++ b/packages/bugsee/src/index.deno.ts @@ -0,0 +1,14 @@ +// bugsee — the DENO entry. Deno is NOT supported (dropped 2026-11-06), and this file exists ONLY to fail loudly. +// +// Deno sets BOTH the `deno` and `node` export conditions. With the `deno` condition removed, a Deno app on +// the single-install path would silently resolve `index.node.ts`: runtime reported as `node`, `Deno.serve` +// uninstrumented, a blind event-loop-lag trace, and `captureLocalVariables` free to freeze the process at +// launch (all measured on the old `@bugsee/deno`). Keeping the condition and throwing here turns that silent +// misbehaviour into an immediate, explained error. It must stay listed BEFORE `node` in package.json +// `exports` (see `test/umbrella-conditions.e2e.ts`). +export {}; + +throw new Error( + '@bugsee/bugsee: Deno is no longer supported. Use Node.js, Bun or a browser. ' + + 'Pin an earlier @bugsee/bugsee version if you must stay on Deno.', +); diff --git a/packages/bugsee/tsup.config.ts b/packages/bugsee/tsup.config.ts index cadd87393..c814e89a0 100644 --- a/packages/bugsee/tsup.config.ts +++ b/packages/bugsee/tsup.config.ts @@ -11,6 +11,7 @@ export default defineConfig({ 'src/index.ts', 'src/index.node.ts', 'src/index.bun.ts', + 'src/index.deno.ts', 'src/index.workerd.ts', 'src/index.edge-light.ts', 'src/index.worker.ts', diff --git a/packages/instrumentation-tests/test/umbrella-conditions.e2e.ts b/packages/instrumentation-tests/test/umbrella-conditions.e2e.ts index cf4d28b00..1c161023a 100644 --- a/packages/instrumentation-tests/test/umbrella-conditions.e2e.ts +++ b/packages/instrumentation-tests/test/umbrella-conditions.e2e.ts @@ -97,6 +97,8 @@ describe('the umbrella resolves the right entry per runtime', () => { }, { runtime: 'a Web Worker build', conditions: ['worker', 'browser'], entry: 'index.worker.ts' }, { runtime: 'Bun', conditions: ['bun', 'node'], entry: 'index.bun.ts' }, + // Deno is unsupported, but keeps its condition so it hits a throwing stub rather than the node build. + { runtime: 'Deno (unsupported: throws)', conditions: ['deno', 'node'], entry: 'index.deno.ts' }, // The two canaries: without them, "the specific runtimes win" is satisfied by a map that never // resolves the general ones at all. { runtime: 'plain node', conditions: ['node'], entry: 'index.node.ts' }, @@ -111,7 +113,7 @@ describe('the umbrella resolves the right entry per runtime', () => { it('every declared condition resolves to a DISTINCT entry', () => { // A duplicate would mean a condition silently aliases another runtime's composition — the exact shape - // of the original defect, where bun resolved the node entry. + // of the original defect, where bun and deno both resolved the node entry. const entries = CASES.map((c) => c.entry); expect(new Set(entries).size).toBe(entries.length); }); diff --git a/packages/trackers/README.md b/packages/trackers/README.md index 20874878f..8d763ddd8 100644 --- a/packages/trackers/README.md +++ b/packages/trackers/README.md @@ -26,7 +26,7 @@ The `./browser` entry exports the `ApplicationTracker` (`applicationTrackerFor`, Page zoom: the `UiTracker` `screenSize` state carries `zoom` and `deviceScale` (`devicePixelRatio / zoom`) only when the derivation is trusted: Chromium, the top-level window, a pointer-fine device, and `outerWidth / innerWidth` within 1.5% of a browser zoom preset (it is snapped to the preset). Otherwise both are omitted and consumers use `devicePixelRatio` alone (docked DevTools, custom zoom, Firefox and Safari). Electron key window: `ElectronApplicationTracker.keyWindowBounds()` (focused window, else most recently focused, else the first visible/created one; new `windowMoved` stage) feeds `ElectronDisplayTracker`'s `keyWindowBounds` seam, which numbers `displays` ids statelessly (key window's display is `0`, the rest ascending by Electron id). -The `./node` entry is shared by Node and Bun and exports the process `ProcessTracker` (`processTrackerFor`, `resetProcessTracker`; a per-process singleton, keyed on the `process` object by default). Its eight stages (`memory`, `systemMemory`, `cpu`, `eventLoop`, `utilization`, `gc`, `v8Heap`, `memoryLimit`) are each armed only while they have listeners, behind one shared sampling timer. The `utilization` stage reports `{ utilizationPercent }` (percent 0-100, one decimal, of the window the loop was not idle; `createGuardedElu` converts perf_hooks' 0..1 fraction). The `gc` stage feeds the `gc` system event (not a trace). A stage the runtime cannot honestly measure emits nothing rather than zero (event-loop utilization on Bun/Deno is dropped by its own tell, idle and active both zero; the event-loop delay histogram on Deno, the GC observer on Bun/Deno, and the V8 heap on Bun are gated by the `measures*` flags the platform packages pass in). `systemMemory.free` is memory available to new work in bytes (Android `availMem`): Electron `process.getSystemMemoryInfo()` or Deno `systemMemoryInfo().available` on macOS first, then `/proc/meminfo` MemAvailable where `readsProcMeminfo` is true (Bun only), then, on macOS only, a rare async `/usr/bin/vm_stat` read (free + file-backed + purgeable pages, the same definition as Electron's `getSystemMemoryInfo`; absolute path, no shell, 2 s timeout, at most one read per 10 s, value served for at most two intervals, single in-flight, killed when the stage loses its last listener, failures omit and are reported once per streak; opt out with `readsVmStat: false`, e.g. `launch(token, { systemTraceProducers: createNodeSystemTraceProducers({ readsVmStat: false }) })`; on Deno it spawns via `Deno.Command` only when the `run` permission for `/usr/bin/vm_stat` is already granted (never prompting), else `Deno.systemMemoryInfo().available`, a larger free+inactive estimate; an unarmed `current()` reads the cache only; a hung child can delay process exit by up to the 2 s timeout; macOS is mostly a developer platform and the spawn happens only while the stage has a listener), then `os.freemem()` (not on macOS, where it is free pages only). It is omitted whenever no source is plausible. Inside a container it is the host's figure; the cap is `process_memory_limit`. The CPU stage has no start value: it reports from the first tick. Seams merge and are never dropped: a later launch that omits `scheduler` or `onError` keeps the previous launch's, and building a producer set already rebinds the shared tracker, so tests that inject fakes need a private `key` or `resetProcessTracker()`. It also exports the guarded runtime sources it is built from (`createGuardedEventLoopSource`, `createGuardedElu`, `createGcSource`, `createV8HeapReader`, `createMemoryLimitReader`, `createSystemFreeReader`, `createElectronMemoryReader`, `createDenoMemoryReader`, `createProcMeminfoReader`, `parseMemAvailable`). +The `./node` entry is shared by Node and Bun and exports the process `ProcessTracker` (`processTrackerFor`, `resetProcessTracker`; a per-process singleton, keyed on the `process` object by default). Its eight stages (`memory`, `systemMemory`, `cpu`, `eventLoop`, `utilization`, `gc`, `v8Heap`, `memoryLimit`) are each armed only while they have listeners, behind one shared sampling timer. The `utilization` stage reports `{ utilizationPercent }` (percent 0-100, one decimal, of the window the loop was not idle; `createGuardedElu` converts perf_hooks' 0..1 fraction). The `gc` stage feeds the `gc` system event (not a trace). A stage the runtime cannot honestly measure emits nothing rather than zero (event-loop utilization on Bun is dropped by its own tell, idle and active both zero; the GC observer and the V8 heap on Bun are gated by the `measures*` flags the platform packages pass in). `systemMemory.free` is memory available to new work in bytes (Android `availMem`): Electron `process.getSystemMemoryInfo()` first, then `/proc/meminfo` MemAvailable where `readsProcMeminfo` is true (Bun only), then, on macOS only, a rare async `/usr/bin/vm_stat` read (free + file-backed + purgeable pages, the same definition as Electron's `getSystemMemoryInfo`; absolute path, no shell, 2 s timeout, at most one read per 10 s, value served for at most two intervals, single in-flight, killed when the stage loses its last listener, failures omit and are reported once per streak; opt out with `readsVmStat: false`, e.g. `launch(token, { systemTraceProducers: createNodeSystemTraceProducers({ readsVmStat: false }) })`; an unarmed `current()` reads the cache only; a hung child can delay process exit by up to the 2 s timeout; macOS is mostly a developer platform and the spawn happens only while the stage has a listener), then `os.freemem()` (not on macOS, where it is free pages only). It is omitted whenever no source is plausible. Inside a container it is the host's figure; the cap is `process_memory_limit`. The CPU stage has no start value: it reports from the first tick. Seams merge and are never dropped: a later launch that omits `scheduler` or `onError` keeps the previous launch's, and building a producer set already rebinds the shared tracker, so tests that inject fakes need a private `key` or `resetProcessTracker()`. It also exports the guarded runtime sources it is built from (`createGuardedEventLoopSource`, `createGuardedElu`, `createGcSource`, `createV8HeapReader`, `createMemoryLimitReader`, `createSystemFreeReader`, `createElectronMemoryReader`, `createProcMeminfoReader`, `parseMemAvailable`). The `./node` entry also exports the disk `StorageTracker` (`storageTrackerFor`, `resetStorageTracker`; one singleton per resolved data directory, so launches over the same directory share a tracker and launches over different directories never affect each other; a launch without a data directory gets the shared inert `process`-keyed tracker, and an explicit `key` overrides, for tests) behind the opt-in `disk_mem_free` / `disk_mem_total` traces. Its one stage, `disk` (`{freeBytes, totalBytes}`), reads the volume of the launch's data directory with `fs.promises.statfs` (not `/` or the working directory) at once when a listener arrives and then on its own unref'd 5 s timer, and does nothing while no one listens, when there is no data directory, or when the runtime has no `statfs`. An unreadable or unsane reading emits nothing (a full disk is a true 0 free), and failures are reported once per failure streak. Within one directory's tracker, `onError`, `scheduler` and `statfs` are latest-launch-wins, an omitted seam keeps the earlier one, and a changed seam is applied (and re-read) immediately. Only the merged seams survive the last unsubscribe; the last reading does not. diff --git a/packages/trackers/src/node/process-tracker.ts b/packages/trackers/src/node/process-tracker.ts index 2d0772a00..56bdb84b8 100644 --- a/packages/trackers/src/node/process-tracker.ts +++ b/packages/trackers/src/node/process-tracker.ts @@ -137,7 +137,7 @@ export interface ProcessEnv { readsVmStat?: boolean; /** Replaces the `vm_stat` sampler (it is stopped when the memory stage loses its last listener). */ vmStat?: VmStatSource; - /** The spawn function for the default `vm_stat` sampler (test seam; default `child_process.execFile`)). */ + /** The spawn function for the default `vm_stat` sampler (test seam; default `child_process.execFile`). */ vmStatExecFile?: ExecFileLike; /** * A runtime-native memory-available-to-new-work reader (bytes), tried before every other free-memory source. Default: diff --git a/packages/trackers/src/node/vm-stat.test.ts b/packages/trackers/src/node/vm-stat.test.ts index 2ce939909..feab71c9f 100644 --- a/packages/trackers/src/node/vm-stat.test.ts +++ b/packages/trackers/src/node/vm-stat.test.ts @@ -343,25 +343,4 @@ describe('createVmStatSampler: cadence, streaks, silent misses', () => { expect(h.sampler.peek()).toBe(10_000 * PAGE); expect(h.calls).toHaveLength(1); }); - - it('canSpawn:false neither spawns nor reports; true spawns', () => { - let allowed = false; - const calls: unknown[] = []; - const errors: unknown[] = []; - const sampler = createVmStatSampler({ - execFile: () => { - calls.push(1); - return { kill: () => true }; - }, - canSpawn: () => allowed, - onError: (e) => errors.push(e), - now: () => 0, - }); - expect(sampler.read()).toBeUndefined(); - expect(calls).toHaveLength(0); - expect(errors).toHaveLength(0); - allowed = true; - sampler.read(); - expect(calls).toHaveLength(1); - }); }); diff --git a/packages/trackers/src/node/vm-stat.ts b/packages/trackers/src/node/vm-stat.ts index ceaf34222..dfb00212b 100644 --- a/packages/trackers/src/node/vm-stat.ts +++ b/packages/trackers/src/node/vm-stat.ts @@ -58,8 +58,6 @@ export interface VmStatOptions { now?: () => number; /** Minimum gap between reads (default 10 000 ms). A value is served for at most two intervals. */ intervalMs?: number; - /** Return false to skip spawning (and answer nothing, without an error) (e.g. a spawn policy that is not granted). */ - canSpawn?: () => boolean; /** Receives the first failure of each failure streak. */ onError?: (error: unknown) => void; } @@ -127,11 +125,7 @@ export function createVmStatSampler(options: VmStatOptions = {}): VmStatSource { return { read() { const t = now(); - if ( - child === undefined && - (lastStart === undefined || t - lastStart >= intervalMs) && - (options.canSpawn?.() ?? true) - ) { + if (child === undefined && (lastStart === undefined || t - lastStart >= intervalMs)) { start(); } return fresh(t); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d5442fda1..cde129de5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -769,7 +769,7 @@ importers: version: 0.8.3 html-webpack-plugin: specifier: ^5.6.8 - version: 5.6.8(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) + version: 5.6.8(webpack@5.112.2(esbuild@0.28.2)) jsdom: specifier: ^25.0.1 version: 25.0.1 @@ -796,16 +796,16 @@ importers: version: 6.0.3 vite: specifier: ^8.3.5 - version: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) + version: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(terser@5.51.2)(tsx@4.23.15) vue: specifier: ^3.5.0 version: 3.5.44(typescript@6.0.3) webpack: specifier: ^5.112.2 - version: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) + version: 5.112.2(esbuild@0.28.2) webpack-subresource-integrity: specifier: ^5.1.0 - version: 5.1.0(html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) + version: 5.1.0(html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)))(webpack@5.112.2(esbuild@0.28.2)) zone.js: specifier: 0.16.3 version: 0.16.3 @@ -15282,7 +15282,7 @@ snapshots: html-void-elements@3.0.0: {} - html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): + html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)): dependencies: '@types/html-minifier-terser': 6.1.0 html-minifier-terser: 6.1.0 @@ -15290,7 +15290,7 @@ snapshots: pretty-error: 4.0.0 tapable: 2.3.3 optionalDependencies: - webpack: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) + webpack: 5.112.2(esbuild@0.28.2) htmlparser2@6.1.0: dependencies: @@ -16032,16 +16032,15 @@ snapshots: postcss: 8.5.32 optional: true - minimizer-webpack-plugin@5.13.1(esbuild@0.28.2)(postcss@8.5.32)(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): + minimizer-webpack-plugin@5.13.1(esbuild@0.28.2)(webpack@5.112.2(esbuild@0.28.2)): dependencies: '@jridgewell/trace-mapping': 0.3.31 jest-worker: 27.5.1 - schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) + schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)) terser: 5.51.2 - webpack: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) + webpack: 5.112.2(esbuild@0.28.2) optionalDependencies: esbuild: 0.28.2 - postcss: 8.5.32 minipass@7.1.3: {} @@ -17643,14 +17642,14 @@ snapshots: webpack: 5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32) optional: true - schema-utils@4.8.1(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): + schema-utils@4.8.1(webpack@5.112.2(esbuild@0.28.2)): dependencies: '@types/json-schema': 7.0.15 ajv: 8.20.0 ajv-formats: 3.0.1(ajv@8.20.0) ajv-keywords: 5.1.0(ajv@8.20.0) optionalDependencies: - webpack: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) + webpack: 5.112.2(esbuild@0.28.2) scule@1.3.0: {} @@ -18832,6 +18831,20 @@ snapshots: tsx: 4.23.15 yaml: 2.9.1 + vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(terser@5.51.2)(tsx@4.23.15): + dependencies: + lightningcss: 1.33.0 + picomatch: 4.0.7 + postcss: 8.5.32 + rolldown: 1.2.15 + tinyglobby: 0.2.17 + optionalDependencies: + '@types/node': 22.20.5 + esbuild: 0.28.2 + fsevents: 2.3.3 + terser: 5.51.2 + tsx: 4.23.15 + vitefu@1.1.3(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)): optionalDependencies: vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) @@ -18987,16 +19000,16 @@ snapshots: webpack-sources@3.6.0: {} - webpack-subresource-integrity@5.1.0(html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): + webpack-subresource-integrity@5.1.0(html-webpack-plugin@5.6.8(webpack@5.112.2(esbuild@0.28.2)))(webpack@5.112.2(esbuild@0.28.2)): dependencies: typed-assert: 1.0.9 - webpack: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) + webpack: 5.112.2(esbuild@0.28.2) optionalDependencies: - html-webpack-plugin: 5.6.8(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) + html-webpack-plugin: 5.6.8(webpack@5.112.2(esbuild@0.28.2)) webpack-virtual-modules@0.6.2: {} - webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32): + webpack@5.112.2(esbuild@0.28.2): dependencies: '@types/estree': 1.0.9 '@types/json-schema': 7.0.15 @@ -19010,8 +19023,8 @@ snapshots: events: 3.3.0 graceful-fs: 4.2.11 mime-db: 1.54.0 - minimizer-webpack-plugin: 5.13.1(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) - schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + minimizer-webpack-plugin: 5.13.1(esbuild@0.28.2)(webpack@5.112.2(esbuild@0.28.2)) + schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)) tapable: 2.3.3 watchpack: 2.6.3 webpack-sources: 3.6.0 @@ -19032,9 +19045,8 @@ snapshots: - sharp - svgo - uglify-js - optional: true - webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32): + webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32): dependencies: '@types/estree': 1.0.9 '@types/json-schema': 7.0.15 @@ -19048,8 +19060,8 @@ snapshots: events: 3.3.0 graceful-fs: 4.2.11 mime-db: 1.54.0 - minimizer-webpack-plugin: 5.13.1(esbuild@0.28.2)(postcss@8.5.32)(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) - schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) + minimizer-webpack-plugin: 5.13.1(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + schema-utils: 4.8.1(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) tapable: 2.3.3 watchpack: 2.6.3 webpack-sources: 3.6.0 @@ -19070,6 +19082,7 @@ snapshots: - sharp - svgo - uglify-js + optional: true whatwg-encoding@3.1.1: dependencies: