Skip to content

fix: infer browser source for browser runtime context - #1384

Open
Tyagiquamar wants to merge 1 commit into
getsentry:mainfrom
Tyagiquamar:fix/browser-runtime-source-inference
Open

Tyagiquamar wants to merge 1 commit into
getsentry:mainfrom
Tyagiquamar:fix/browser-runtime-source-inference

Conversation

@Tyagiquamar

Copy link
Copy Markdown
Contributor

Summary

Envelopes from browser SDKs whose events carry contexts.runtime.name = "browser" are now classified as browser instead of server when no browser User-Agent is available. This corrects the source label shown in the human, logfmt, markdown, and JSON formatters and in the log stream.

Root Cause

inferSourceFromEvent in packages/spotlight/src/server/formatters/human/utils.ts treated any non-empty event.contexts.runtime.name as a deterministic server signal and returned "server" immediately. Browser SDKs emit contexts.runtime.name = "browser", so such events were misclassified before the later SDK-name fallback could classify them as "browser". The user-agent signal masks this in the common case because a real browser request carries a browser User-Agent, but the sidecar can receive envelopes with no User-Agent (proxying, server-side forwarding, or privacy tooling that strips it), which exposed the wrong classification.

Issue #757 in this repository is a separate, older tab-count reactivity problem and is not addressed here.

Solution

One line in inferSourceFromEvent: keep the runtime-context server heuristic, but exclude the literal "browser" runtime name. This is the narrowest change that preserves all existing server detection (for example node, CPython, or ruby) while letting browser SDK events reach the existing browser SDK-name fallback.

A regression test was added at packages/spotlight/src/server/formatters/human/__tests__/utils.test.ts with two cases: a browser runtime context must infer browser, and a non-browser runtime context must still infer server.

Test Plan

Validation ran in Docker with image node:22-bookworm. Because a full pnpm install --frozen-lockfile was prohibitively slow in this environment, an isolated harness was used: vitest@4.1.12, chalk@5.6.2, and @biomejs/biome@1.9.4 were installed with npm i --legacy-peer-deps, and the exact repository source files were copied into the harness. The repository's own biome.json was passed via --config-path.

Commands and real results:

  • npx vitest run src/packages/spotlight/src/server/formatters/human/__tests__/utils.test.ts (with fix): 1 test file passed, 2 tests passed.
  • Base proof, after replacing the harness copy of utils.ts with git -C /repo show HEAD:packages/spotlight/src/server/formatters/human/utils.ts: 1 test file failed, 1 test failed and 1 passed, with AssertionError: expected 'server' to be 'browser'.
  • npx biome check --config-path=/repo/biome.json <the two changed files> (LF-normalized copies, matching CI checkout): Checked 2 files in 53ms. No fixes applied. Zero errors.
  • git diff --check: exit 0.

Not run locally: full pnpm install, full pnpm test, and pnpm build. These are deferred to GitHub Actions CI.

@vercel

vercel Bot commented Nov 18, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
spotlightjs Skipped Skipped Nov 18, 2026 9:48am UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 732b941f Deployed Nov 20, 2026 by Tyagiquamar via Build #2470
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants