fix(sdk-ts): build Linux Chrome candidates with POSIX path semantics on every host

DZ
3d ago
+9-2

Summary

chromeCandidates() in packages/sdk-ts/src/browser/localBrowser.ts is parameterized by the target platform, and its branches disagreed about path semantics:

  • the darwin branch returns literal POSIX strings,
  • the win32 branch builds candidates with path.win32.join,
  • the linux branch used the host's path.join and path.delimiter.

On a Windows host, the Linux branch therefore split PATH on ; instead of : and joined candidate directories with backslashes, so resolving Chrome for a Linux platform produced paths like \usr\bin\chromium that can never match a POSIX executable, and launchChrome threw "Chrome installation not found; set CHROME_PATH". This is not hypothetical: the repo's own test packages/sdk-ts/tests/browser/localBrowser.test.ts > local browser launch lifecycle > discovers Windows and Linux installations using platform conventions injects platform: "linux" with a POSIX PATH and fails on Windows hosts today, while the equivalent injected-win32 case in the same test passes because of the explicit path.win32.join.

This change makes the Linux branch use path.posix.delimiter and path.posix.join, so every branch of chromeCandidates is host-independent. Behavior on POSIX hosts is byte-identical (path.posix.join/path.posix.delimiter equal path.join/path.delimiter there); on Windows hosts the Linux branch now returns correct POSIX candidates. No production call site passes a platform other than process.platform, so nothing changes for Linux users running the SDK on Linux — the fix removes the host-dependence and repairs the faked-platform path exercised by the existing test.

A patch changeset for @browserbasehq/stagehand is included, matching the repository's changeset convention.

Validation

  • packages/sdk-ts/tests/browser/localBrowser.test.ts (25 tests) fails on Windows before this change (discovers Windows and Linux installations using platform conventions → Error: Chrome installation not found; set CHROME_PATH from the injected-Linux case at test line 298) and passes 25/25 after it. Red/green logs attached to the contribution package.
  • Full sdk-ts unit suite on the same Windows machine: 623 passed / 9 failed at base 4d72a87 → 624 passed / 8 failed with this change (the fixed failure is the localBrowser test above). The 8 remaining failures are pre-existing and unrelated — see below.
  • npx tsc --noEmit -p packages/sdk-ts/tsconfig.json — clean (exit 0).
  • oxfmt --check and oxlint on the touched file — clean; git diff --check — clean.
  • The 8 remaining suite failures were verified pre-existing at the base commit and unrelated to this change: packageContract.test.ts (execFile("pnpm") ENOENT for .cmd shims on Windows), objectWrapper.test.ts (Node/libuv on Windows reports pre-1970 mtimeMs wrapped to a positive uint32-seconds value, so the SDK's lastModified < 0 guard never triggers), browserbaseTransport.test.ts (an undici body-resume timer from an earlier real-fetch test lands on the later test's fake clock — cross-test pollution, confirmed with stack traces; the transport's own timer is cleared correctly), and 5 in factories.test.ts (packaged-extension environment on this machine).

AI assistance

Prepared with an AI coding agent (ZCode) working from a maintainer-reviewed diagnosis; the analysis, fix, and validation were verified locally as described above.


Summary by cubic

Fixes the Linux branch of chromeCandidates() so Chrome candidate paths are built with POSIX semantics on every host. On Windows hosts, the branch previously joined candidate directories with backslashes and split PATH on ;, so Linux Chrome candidates could never match and launchLocalBrowser threw Chrome installation not found; set CHROME_PATH.

  • The Linux branch now uses path.posix.join and path.posix.delimiter, matching how the win32 branch already forces its target's semantics.
  • Paths produced on POSIX hosts are unchanged; the fix only affects calls with a non-native platform argument, which no production call site makes.
  • Includes a patch changeset for @browserbasehq/stagehand.