Skip to content

fix(utils): correctly detect Deno runtime in User-Agent header - #199

Open
pylrn wants to merge 2 commits into
AssemblyAI:mainfrom
pylrn:fix/deno-user-agent-detection
Open

pylrn wants to merge 2 commits into
AssemblyAI:mainfrom
pylrn:fix/deno-user-agent-detection

Conversation

@pylrn

@pylrn pylrn commented Oct 22, 2026

Copy link
Copy Markdown

Summary

Fixes a copy-paste bug in src/utils/userAgent.ts where Deno runtime detection mistakenly checked process.versions.bun instead of Deno's own version properties:

// Before
if (typeof Deno !== "undefined") {
  if (process.versions.bun && defaultUserAgentString.indexOf("Deno") === -1) {
    defaultUserAgent.runtime_env = { name: "Deno", version: Deno.version.deno };
  }
}

In standard Deno environments without Node compatibility layers, process is undefined and evaluating process.versions.bun could throw a ReferenceError. Even with polyfilled process, process.versions.bun was never truthy, causing Deno runtime identification in the SDK's telemetry header to silently fail.

Changes

  • Fix Deno runtime detection to inspect Deno.version?.deno.
  • Refactor detector resolution into detectDefaultUserAgent(env?: EnvironmentDetectors) for clean testability and safe environment property access without ReferenceError.
  • Add unit tests in tests/unit/utils.test.ts verifying Deno, Bun, and Node environment detection.
  • Passes eslint, prettier, and tsc --noEmit cleanly.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant