dmtrKovalenko/fff · error · Error

Unsupported platform

Error message

Unsupported platform: ${platform}

What it means

getTriple() maps process.platform to a Rust-style OS segment of a target triple and only recognizes darwin, android, linux, and win32. Running on any other process.platform value (or calling it in a non-Node-like host where process.platform is unexpected) throws this error.

Solutions

  1. Run the library only on supported platforms (macOS, Linux, Windows, Android).
  2. If on FreeBSD/OpenBSD etc., build the native lib manually and avoid code paths that resolve npm packages by triple.
  3. Fix test mocks to use a real platform value such as 'linux' when stubbing process.platform.

Example fix

// before (test stub)
process.platform = 'freebsd';
// after
process.platform = 'linux';
// or guard before calling
if (!['darwin','linux','win32','android'].includes(process.platform)) throw new Error('unsupported');
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = ['darwin','android','linux','win32'];
if (!SUPPORTED.includes(process.platform)) throw new Error(`unsupported platform ${process.platform}`);

Type guard

function isSupportedPlatform(p: NodeJS.Platform): p is 'darwin'|'android'|'linux'|'win32' {
  return p === 'darwin' || p === 'android' || p === 'linux' || p === 'win32';
}

Prevention

When it happens

Trigger: Calling getTriple() (directly or through triple/getNpmPackageName) while process.platform is not one of darwin|android|linux|win32 — e.g. exotic embedded runtimes, mocked platforms in tests, or JavaScript engines that report an unusual platform string.

Common situations: Unit tests that stub process.platform with an invalid value, bundlers/SSR environments where process.platform is undefined or 'browser', or truly unsupported OSes like freebsd/openbsd running bun or node.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of dmtrKovalenko/fff@7f8537e70f (2026-09-10). Data as JSON: /api/errors/22debbe458950b79. Report an issue: GitHub.

Appendix: source

Thrown at packages/fff-bun/src/platform.ts:24

/**
 * Get the platform triple (e.g., "x86_64-unknown-linux-gnu")
 */
export function getTriple(): string {
  const platform = process.platform;
  const arch = process.arch;

  let osName: string;
  if (platform === "darwin") {
    osName = "apple-darwin";
  } else if (platform === "android") {
    osName = "linux-android";
  } else if (platform === "linux") {
    osName = detectLinuxLibc();
  } else if (platform === "win32") {
    osName = "pc-windows-msvc";
  } else {
    throw new Error(`Unsupported platform: ${platform}`);
  }

  const archName = normalizeArch(arch);
  return `${archName}-${osName}`;
}

/**
 * Detect whether we're on musl or glibc Linux
 */
function detectLinuxLibc(): string {
  let output = "";
  try {
    output = execSync("ldd --version 2>&1", {
      encoding: "utf-8",
      timeout: 5000,
    });
  } catch (e: unknown) {
    // Alpine/musl: `ldd --version` exits with code 1 but still prints

View on GitHub (pinned to 7f8537e70f)