{"record":{"id":"dbd233babff8ddf4","repo":"stablyai/orca","slug":"node-pty-is-missing-sourcefile","errorCode":null,"errorMessage":"node-pty is missing ${sourceFile}","messagePattern":"node-pty is missing (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/rebuild-native-deps.mjs","lineNumber":191,"sourceCode":"  const nodePtyDir = resolve(projectDir, 'node_modules', 'node-pty')\n  if (!existsSync(join(nodePtyDir, 'build', 'Release', 'conpty.node'))) {\n    return\n  }\n  const conptyRoot = join(nodePtyDir, 'third_party', 'conpty')\n  const sourceDir = readdirSync(conptyRoot, { withFileTypes: true })\n    .filter((entry) => entry.isDirectory())\n    .map((entry) => join(conptyRoot, entry.name, `win10-${rebuildArch}`))\n    .find((candidate) => existsSync(candidate))\n  if (!sourceDir) {\n    throw new Error(`node-pty has no ConPTY runtime payload for win10-${rebuildArch}`)\n  }\n\n  const runtimeDir = join(nodePtyDir, 'build', 'Release', 'conpty')\n  mkdirSync(runtimeDir, { recursive: true })\n  for (const filename of NODE_PTY_CONPTY_RUNTIME_FILES) {\n    const sourceFile = join(sourceDir, filename)\n    if (!existsSync(sourceFile)) {\n      throw new Error(`node-pty is missing ${sourceFile}`)\n    }\n    copyFileSync(sourceFile, join(runtimeDir, filename))\n  }\n  // Why: @electron/rebuild bypasses node-pty's postinstall step that normally copies these DLLs.\n  console.log(`[rebuild] Restored node-pty ConPTY runtime files for win10-${rebuildArch}.`)\n}\n\nfunction ensureElectronPackageInstalled() {\n  if (electronPackageIsUsable()) {\n    return\n  }\n\n  // Why: CI has observed Electron's postinstall exiting cleanly without\n  // writing path.txt. Electron 42's lazy require() would run install.js here,\n  // so inspect dist/ directly and keep using our strict partial-extract checks.\n  console.log('[rebuild] Electron package binary is missing; installing Electron package binary.')\n  resetPartialElectronInstall()\n  try {","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/rebuild-native-deps.mjs#L173-L209","documentation":"Thrown by the ConPTY-restore step in config/scripts/rebuild-native-deps.mjs when the per-arch source payload directory was found, but one of the files in NODE_PTY_CONPTY_RUNTIME_FILES (the expected ConPTY DLL set) is absent inside it. This means node-pty's bundled payload is incomplete — the directory exists but is missing a required DLL, so copying the runtime set cannot complete.","triggerScenarios":"On Windows, after rebuild, the sourceDir `win10-<arch>` exists but is missing one of the entries in NODE_PTY_CONPTY_RUNTIME_FILES (e.g. conpty.dll was deleted, or a partial extract left only some files). The loop at lines 188-192 throws on the first missing sourceFile.","commonSituations":"A previous interrupted npm install or cache corruption left the ConPTY payload half-populated; an antivirus quarantined one of the Microsoft ConPTY DLLs; or a node-pty version change altered the expected file list while an old payload dir lingered.","solutions":["Fully reinstall node-pty to repopulate the entire win10-<arch> payload directory.","Clear the npm/pnpm cache (`npm cache clean --force`) before reinstalling if corruption is suspected.","Check antivirus/quarantine logs if a specific DLL keeps disappearing after restore."],"exampleFix":"// before\n# node-pty/third_party/conpty/<ver>/win10-x64 exists but is missing conpty.dll\nnode config/scripts/rebuild-native-deps.mjs --platform win32\n\n// after\nrm -rf node_modules/node-pty && npm install\nnode config/scripts/rebuild-native-deps.mjs --platform win32","handlingStrategy":"validation","validationCode":"import { existsSync, readdirSync } from 'node:fs'\nimport { join } from 'node:path'\n\nconst conptyRoot = join('node_modules', 'node-pty', 'third_party', 'conpty')\nconst arch = process.env.npm_config_arch || process.arch\nconst sourceDir = readdirSync(conptyRoot, { withFileTypes: true })\n  .filter((e) => e.isDirectory())\n  .map((e) => join(conptyRoot, e.name, `win10-${arch}`))\n  .find(existsSync)\n// Verify every expected DLL is present before rebuilding\nconst expected = ['conpty.dll'] // subset of NODE_PTY_CONPTY_RUNTIME_FILES\nconst missing = expected.filter((f) => !existsSync(join(sourceDir, f)))\nif (missing.length) throw new Error(`Incomplete ConPTY payload, missing: ${missing.join(', ')}`)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reinstall node-pty fully rather than partially restoring the payload dir.","Clear npm cache if a DLL is repeatedly missing after reinstall (cache corruption).","Check antivirus quarantine if a specific ConPTY DLL keeps disappearing."],"tags":["native","windows","node-pty","conpty","build","rebuild"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}