{"record":{"id":"9dd564c9343ba3fe","repo":"stablyai/orca","slug":"unsupported-packaged-runtime-architecture-strin","errorCode":null,"errorMessage":"Unsupported packaged runtime architecture: ${String(electronArch)}","messagePattern":"Unsupported packaged runtime architecture: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/packaged-runtime-node-modules.cjs","lineNumber":272,"sourceCode":"}\n\nfunction normalizeNodePtyWindowsArch(electronArch) {\n  const architecture = normalizeElectronArchitecture(electronArch)\n  if (architecture !== 'x64' && architecture !== 'arm64') {\n    throw new Error(`Unsupported packaged node-pty Windows architecture: ${architecture}`)\n  }\n  return architecture\n}\n\nfunction normalizeElectronArchitecture(electronArch) {\n  const architecture =\n    typeof electronArch === 'number'\n      ? ELECTRON_ARCHITECTURE_BY_ENUM[electronArch]\n      : electronArch === 'armv7l'\n        ? 'arm'\n        : electronArch\n  if (!PACKAGED_NATIVE_ARCHITECTURES.has(architecture)) {\n    throw new Error(`Unsupported packaged runtime architecture: ${String(electronArch)}`)\n  }\n  return architecture\n}\n\nfunction pruneNodePtyNativeDirectories(directory, platformPrefix, electronArch, allowsSuffix) {\n  if (!existsSync(directory)) {\n    return\n  }\n  const architecture = normalizeElectronArchitecture(electronArch)\n  const targetPrefix = `${platformPrefix}${architecture}`\n  const platformPrefixes = Object.values(NODE_PTY_PREBUILD_PREFIX_BY_PLATFORM)\n  for (const entry of readdirSync(directory, { withFileTypes: true })) {\n    if (!entry.isDirectory() || !platformPrefixes.some((prefix) => entry.name.startsWith(prefix))) {\n      continue\n    }\n    const matchesTarget =\n      entry.name.startsWith(platformPrefix) &&\n      (entry.name === targetPrefix || (allowsSuffix && entry.name.startsWith(`${targetPrefix}-`)))","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/packaged-runtime-node-modules.cjs#L254-L290","documentation":"The `normalizeElectronArchitecture` function converts the electron-builder arch value (either a numeric Arch enum or a string) to a normalized name and checks it against PACKAGED_NATIVE_ARCHITECTURES ({ia32, x64, arm, arm64}). If the normalized value isn't in that set — e.g., 'universal' (enum 4), undefined (unknown enum), or an unrecognized string — the build fails. This guards all architecture-dependent packaging steps (node-pty pruning, parcel-watcher pruning).","triggerScenarios":"Building for 'universal' (context.arch === 4) — universal is not in PACKAGED_NATIVE_ARCHITECTURES because pruning needs a concrete arch, not a merged one. An unrecognized arch string passed to the packaging step. A future Electron arch enum value not in ELECTRON_ARCHITECTURE_BY_ENUM (which maps 0-4), resulting in undefined.","commonSituations":"Configuring a universal macOS build that triggers the pruning path. Electron-builder passing an unexpected arch value. Adding a new architecture (e.g., riscv64) without updating the supported set. The armv7l string alias (mapped to 'arm' at line 269) working, but other strings not being handled.","solutions":["Check what `electronArch` value is being passed — log it at the call site. If it's a number, cross-reference ELECTRON_ARCHITECTURE_BY_ENUM at line 47.","If building universal, the pruning functions need to handle 'universal' specially (run for each slice) rather than passing it to normalizeElectronArchitecture — see how electron-builder.config.cjs:251 handles `context.arch === 4` for boot verification.","If you added a new architecture, add it to both ELECTRON_ARCHITECTURE_BY_ENUM and PACKAGED_NATIVE_ARCHITECTURES.","For unrecognized string archs, add the alias mapping at line 268-270."],"exampleFix":"// before — universal arch fails\nPACKAGED_NATIVE_ARCHITECTURES = new Set(['ia32', 'x64', 'arm', 'arm64'])\n// context.arch === 4 → 'universal' → not in set → throws\n\n// after — handle universal by iterating slices\nif (architecture === 'universal') {\n  normalizeElectronArchitecture('x64')\n  normalizeElectronArchitecture('arm64')\n  return\n}","handlingStrategy":"validation","validationCode":"// Verify arch is in the supported set before pruning native modules\nconst PACKAGED_NATIVE_ARCHITECTURES = new Set(['ia32', 'x64', 'arm', 'arm64'])\nfunction assertSupportedRuntimeArch(electronArch) {\n  const map = { 0: 'ia32', 1: 'x64', 2: 'arm', 3: 'arm64', 4: 'universal' }\n  let arch = typeof electronArch === 'number' ? map[electronArch] : electronArch\n  if (arch === 'armv7l') arch = 'arm'\n  if (!PACKAGED_NATIVE_ARCHITECTURES.has(arch)) {\n    throw new Error(`Unsupported arch: ${String(electronArch)} (normalized: ${arch})`)\n  }\n}","typeGuard":"function isSupportedRuntimeArch(arch: string): arch is 'ia32' | 'x64' | 'arm' | 'arm64' {\n  return ['ia32', 'x64', 'arm', 'arm64'].includes(arch)\n}","tryCatchPattern":null,"preventionTips":["Handle 'universal' builds specially before calling normalizeElectronArchitecture — iterate over each slice instead.","Update ELECTRON_ARCHITECTURE_BY_ENUM and PACKAGED_NATIVE_ARCHITECTURES together when adding a new architecture.","Log the incoming arch value when debugging — a number means it's from electron-builder's enum, a string means it's already normalized."],"tags":["packaging","architecture","native-modules","electron-builder","multi-arch"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}