Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions test/interop/clients/js/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @module
*/
import { randomUUID } from "node:crypto";
import { realpathSync } from "node:fs";
import { join } from "node:path";
import {
type Browser,
Expand Down Expand Up @@ -119,20 +120,22 @@ export function launch(args: string[] = [], engine: Engine = "chromium"): Promis
// Full Chromium includes WebTransport and WebCodecs; the headless shell does not.
if (engine === "chromium")
return chromium.launch({ channel: "chromium", headless: true, args, handleSIGTERM: false });
if (engine === "firefox")
if (engine === "firefox") {
const env = { ...process.env };
// Only the Nix browser needs Nix's dlopened media libraries. Downloaded Firefox
// uses the system libraries installed by Playwright; mixing in Nix's libraries
// can require a newer glibc than the host's and prevent the audio backend starting.
if (realpathSync(firefox.executablePath()).startsWith("/nix/store/"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

realpathSync throws ENOENT for a non-empty path that does not exist, and Playwright's executablePath() returns the joined browser path without checking that Firefox is installed (it only falls back to "" on an unsupported platform). Before this commit a missing or revision-mismatched browser fell through to firefox.launch() and surfaced Playwright's "Executable doesn't exist … run playwright install firefox" message; now the harness fails earlier with a bare ENOENT. Guarding with existsSync (add it to the existing node:fs import) keeps the Nix check while letting launch() report the actionable error.

Technical details
# Preserve Playwright's missing-browser error

## Affected sites
- `test/interop/clients/js/harness.ts:128` — `realpathSync(firefox.executablePath())` throws `ENOENT` when the browser is absent.

## Required outcome
- An uninstalled Firefox (stale or mismatched `PLAYWRIGHT_BROWSERS_PATH`, a Playwright bump before `playwright install firefox`) still reaches `firefox.launch()` so the user sees the install hint.
- A real `/nix/store/` executable, direct or symlinked, still gets `PLAYWRIGHT_FIREFOX_LIBRARY_PATH`.

## Evidence
- `playwright-core@1.64.1`: the dispatcher sends `executablePath: browserType.executablePath()`, which is `path.join(firefox.dir, "firefox")` from `findExecutablePath` with no existence check; the client throws only when that value is falsy.
- `fs.realpathSync("")` returns the cwd under Node 24 and bun, so the not-yet-installed case specifically surfaces as `ENOENT: no such file or directory, realpath '/…/firefox/firefox'`.
Suggested change
if (realpathSync(firefox.executablePath()).startsWith("/nix/store/"))
const executable = firefox.executablePath();
if (existsSync(executable) && realpathSync(executable).startsWith("/nix/store/"))

@kixelated kixelated Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Published the suggested guard, including its required import, in follow-up moq-dev/moq#8092 because GitHub rejected updates to this queued head. The absent-browser probe now reaches Playwright’s actionable installation error, and just ci passed at 7ff977c6af. The follow-up remains draft until this parent lands and its diff can be narrowed to the diagnostic correction.

(Written by GPT-6.1 Sol with xhigh effort)

env.LD_LIBRARY_PATH = [process.env.PLAYWRIGHT_FIREFOX_LIBRARY_PATH, process.env.LD_LIBRARY_PATH]
.filter(Boolean)
.join(":");
return firefox.launch({
headless: true,
handleSIGTERM: false,
// Firefox dlopens its media libraries. Keep the Nix paths on this child, so other
// browsers and native tools retain their own library search paths.
env: {
...process.env,
LD_LIBRARY_PATH: [process.env.PLAYWRIGHT_FIREFOX_LIBRARY_PATH, process.env.LD_LIBRARY_PATH]
.filter(Boolean)
.join(":"),
},
env,
firefoxUserPrefs: { "media.autoplay.default": 1, "media.autoplay.block-webaudio": true },
});
}
// WebKit's WebCodecs decode through the system GStreamer. The Nix dev shell points GStreamer at
// its own newer plugins, which the system core refuses, leaving WebKit with no decoders at all.
const env = Object.fromEntries(
Expand Down
Loading