microsoft/playwright · error · Error

Unsupported platform: ${process.platform}

Error message

Unsupported platform: ${process.platform}

What it means

Thrown by computeBaseDaemonDir when process.platform is none of linux, darwin, or win32 (and PWTEST_DAEMON_SESSION_DIR is unset). The daemon directory cannot be derived for an unknown platform.

Source

Thrown at packages/playwright-core/src/tools/cli-client/registry.ts:157

      }
    }
    return new Registry(sessions);
  }
}

function computeBaseDaemonDir(): string {
  if (process.env.PWTEST_DAEMON_SESSION_DIR)
    return process.env.PWTEST_DAEMON_SESSION_DIR;

  let localCacheDir: string | undefined;
  if (process.platform === 'linux')
    localCacheDir = process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache');
  if (process.platform === 'darwin')
    localCacheDir = path.join(os.homedir(), 'Library', 'Caches');
  if (process.platform === 'win32')
    localCacheDir = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
  if (!localCacheDir)
    throw new Error('Unsupported platform: ' + process.platform);
  return path.join(localCacheDir, 'ms-playwright', 'daemon');
}

let _baseDaemonDir: string | undefined;

export function baseDaemonDir(): string {
  return _baseDaemonDir ??= computeBaseDaemonDir();
}

export function createClientInfo(): ClientInfo {
  const workspaceDir = findWorkspaceDir(process.cwd());
  const version = process.env.PLAYWRIGHT_CLI_VERSION_FOR_TEST || packageJSON.version;

  const hash = crypto.createHash('sha1');
  hash.update(workspaceDir || packageRoot);
  const workspaceDirHash = hash.digest('hex').substring(0, 16);

  return {

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Set the PWTEST_DAEMON_SESSION_DIR environment variable to an absolute directory to bypass platform detection (note: the env name suggests test usage but it is the only override hook).
  2. Run on a supported platform (linux/darwin/win32).
  3. Confirm process.platform via a tiny node -e check if the failure is unexpected.

Example fix

# before
playwright-cli open   # on freebsd -> throws

# after
export PWTEST_DAEMON_SESSION_DIR=/var/cache/playwright-daemon
playwright-cli open
Defensive patterns

Strategy: validation

Validate before calling

import os from 'os';
const SUPPORTED = new Set(['linux', 'darwin', 'win32']);
function ensurePlatformSupported() {
  if (!SUPPORTED.has(process.platform) && !process.env.PWTEST_DAEMON_SESSION_DIR) {
    throw new Error(`Set PWTEST_DAEMON_SESSION_DIR on platform ${process.platform}`);
  }
}

Type guard

function isSupportedPlatform(): boolean {
  return ['linux', 'darwin', 'win32'].includes(process.platform);
}

Try / catch

// Compute the dir with an env override as a fallback instead of catching.
process.env.PWTEST_DAEMON_SESSION_DIR ??= '/var/cache/playwright-daemon';

Prevention

When it happens

Trigger: Running the playwright CLI daemon on an unsupported OS (e.g. freebsd, aix, sunos) without an explicit override.

Common situations: Running inside unusual containers that report a non-standard platform; CI on an exotic OS; Node build that misreports process.platform.

Related errors


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/dd01c1c0109926b1. Report an issue: GitHub.