Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix: reset SNAP* env variables when launching Firefox (#20692)

Andrey Lushnikovd3c543008066
diff --git a/packages/playwright-core/src/server/firefox/firefox.ts b/packages/playwright-core/src/server/firefox/firefox.ts
index 610ff56ab9..38c6db85d3 100644
--- a/packages/playwright-core/src/server/firefox/firefox.ts
+++ b/packages/playwright-core/src/server/firefox/firefox.ts
@@ -46,6 +46,12 @@ export class Firefox extends BrowserType {
_amendEnvironment(env: Env, userDataDir: string, executable: string, browserArguments: string[]): Env {
if (!path.isAbsolute(os.homedir()))
throw new Error(`Cannot launch Firefox with relative home directory. Did you set ${os.platform() === 'win32' ? 'USERPROFILE' : 'HOME'} to a relative path?`);
+ if (os.platform() === 'linux') {
+ // Always remove SNAP_NAME and SNAP_INSTANCE_NAME env variables since they
+ // confuse Firefox: in our case, builds never come from SNAP.
+ // See https://github.com/microsoft/playwright/issues/20555
+ return { ...env, SNAP_NAME: undefined, SNAP_INSTANCE_NAME: undefined };
+ }
return env;
}