{"record":{"id":"22debbe458950b79","repo":"dmtrKovalenko/fff","slug":"unsupported-platform-platform","errorCode":null,"errorMessage":"Unsupported platform: ${platform}","messagePattern":"Unsupported platform: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/fff-bun/src/platform.ts","lineNumber":24,"sourceCode":"\n/**\n * Get the platform triple (e.g., \"x86_64-unknown-linux-gnu\")\n */\nexport function getTriple(): string {\n  const platform = process.platform;\n  const arch = process.arch;\n\n  let osName: string;\n  if (platform === \"darwin\") {\n    osName = \"apple-darwin\";\n  } else if (platform === \"android\") {\n    osName = \"linux-android\";\n  } else if (platform === \"linux\") {\n    osName = detectLinuxLibc();\n  } else if (platform === \"win32\") {\n    osName = \"pc-windows-msvc\";\n  } else {\n    throw new Error(`Unsupported platform: ${platform}`);\n  }\n\n  const archName = normalizeArch(arch);\n  return `${archName}-${osName}`;\n}\n\n/**\n * Detect whether we're on musl or glibc Linux\n */\nfunction detectLinuxLibc(): string {\n  let output = \"\";\n  try {\n    output = execSync(\"ldd --version 2>&1\", {\n      encoding: \"utf-8\",\n      timeout: 5000,\n    });\n  } catch (e: unknown) {\n    // Alpine/musl: `ldd --version` exits with code 1 but still prints","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/packages/fff-bun/src/platform.ts#L6-L42","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the library only on supported platforms (macOS, Linux, Windows, Android).","If on FreeBSD/OpenBSD etc., build the native lib manually and avoid code paths that resolve npm packages by triple.","Fix test mocks to use a real platform value such as 'linux' when stubbing process.platform."],"exampleFix":"// before (test stub)\nprocess.platform = 'freebsd';\n// after\nprocess.platform = 'linux';\n// or guard before calling\nif (!['darwin','linux','win32','android'].includes(process.platform)) throw new Error('unsupported');","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['darwin','android','linux','win32'];\nif (!SUPPORTED.includes(process.platform)) throw new Error(`unsupported platform ${process.platform}`);","typeGuard":"function isSupportedPlatform(p: NodeJS.Platform): p is 'darwin'|'android'|'linux'|'win32' {\n  return p === 'darwin' || p === 'android' || p === 'linux' || p === 'win32';\n}","tryCatchPattern":null,"preventionTips":["Check process.platform before calling triple-based APIs on exotic OSes.","Use real platform values when stubbing process.platform in tests.","Avoid running the binary-resolution path in browsers/SSR environments."],"tags":["platform","unsupported-platform","bun"],"backgroundTag":"unsupported-platform","analyzedSha":"7f8537e70f0ea1210f9acbbfc4640141105cdc78","analyzedAt":"2026-09-10T07:26:53.407Z","contentChangedAt":"2026-09-10T07:26:53.407Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}