{"record":{"id":"27366fb15980e150","repo":"stablyai/orca","slug":"verify-packaged-daemon-entry-packaged-daemon-ent-27366f","errorCode":null,"errorMessage":"[verify-packaged-daemon-entry] packaged daemon-entry.js did not reach argv parsing (expected the \"Usage: daemon-entry\" error). stderr:\n${stderr}","messagePattern":"\\[verify-packaged-daemon-entry\\] packaged daemon-entry\\.js did not reach argv parsing \\(expected the \"Usage: daemon-entry\" error\\)\\. stderr:\n(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/scripts/verify-packaged-daemon-entry.cjs","lineNumber":50,"sourceCode":"// <appOutDir>/resources elsewhere). execPath defaults to the packaging Node.\nfunction verifyPackagedDaemonEntryBoots(resourcesDir, options = {}) {\n  const execPath = options.execPath || process.execPath\n  const entryPath = assertPackagedDaemonEntryExists(resourcesDir)\n\n  const result = spawnSync(execPath, [entryPath], { encoding: 'utf8', timeout: 10_000 })\n  if (result.error) {\n    throw new Error(\n      `[verify-packaged-daemon-entry] could not launch daemon-entry.js: ${result.error.message}`\n    )\n  }\n  const stderr = result.stderr || ''\n  if (/Cannot find module|MODULE_NOT_FOUND/.test(stderr)) {\n    throw new Error(\n      `[verify-packaged-daemon-entry] packaged daemon-entry.js failed to load under plain Node:\\n${stderr}`\n    )\n  }\n  if (!stderr.includes('Usage: daemon-entry')) {\n    throw new Error(\n      `[verify-packaged-daemon-entry] packaged daemon-entry.js did not reach argv parsing ` +\n        `(expected the \"Usage: daemon-entry\" error). stderr:\\n${stderr}`\n    )\n  }\n  console.log('[verify-packaged-daemon-entry] OK — packaged daemon-entry loads under plain Node')\n}\n\nmodule.exports = { assertPackagedDaemonEntryExists, verifyPackagedDaemonEntryBoots }\n","sourceCodeStart":32,"sourceCodeEnd":59,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/verify-packaged-daemon-entry.cjs#L32-L59","documentation":"Thrown by the packaged daemon entry verification script when daemon-entry.js launched successfully under plain Node, loaded without MODULE_NOT_FOUND errors, but did not print the expected 'Usage: daemon-entry' usage message to stderr. The script expects that with no arguments, the entry reaches its argv parsing logic and prints a usage error. The absence of this line means the entry's argument handling changed or the process exited before reaching argv parsing.","triggerScenarios":"The daemon entry's argv parsing code was refactored and the usage message text or format changed; the entry now exits with a different code path when no args are provided (e.g., it starts the daemon instead of printing usage); the entry now prints usage to stdout instead of stderr; the entry crashes silently before reaching the argv check.","commonSituations":"A developer changed the no-args behavior of daemon-entry.js to auto-start instead of printing usage; the usage string was reworded (e.g., 'Usage: daemon-entry' became 'Usage: orca-daemon'); the argv parser library was swapped and the new one outputs differently; stderr buffering caused the usage line to not be captured within the 10-second timeout.","solutions":["Run the packaged daemon-entry.js manually under plain Node with no args and check what it prints: node <resourcesDir>/app.asar.unpacked/out/main/daemon-entry.js","If the usage message text changed, update the assertion in verify-packaged-daemon-entry.cjs line 49 to match the new expected string.","If the no-args behavior changed intentionally (e.g., it now starts the daemon), reconsider the verification strategy — the check assumes no-args prints usage, so either restore that contract or redesign the test.","Ensure the entry flushes stderr before exiting; a process.exit() before stderr drain can cause the line to be missed."],"exampleFix":"// before — daemon entry changed its usage message\n//   if (!stderr.includes('Usage: daemon-entry')) { ... }\n//\n// after — update the assertion to match the new usage string\n//   if (!stderr.includes('Usage: orca-daemon-entry')) { ... }","handlingStrategy":"validation","validationCode":"// Before packaging, verify the daemon entry prints its usage line under plain Node.\nconst { spawnSync } = require('node:child_process')\n\nfunction preCheckDaemonUsage(entryPath, expectedUsage = 'Usage: daemon-entry') {\n  const result = spawnSync(process.execPath, [entryPath], {\n    encoding: 'utf8',\n    timeout: 10_000\n  })\n  const stderr = result.stderr || ''\n  if (!stderr.includes(expectedUsage)) {\n    return { ok: false, actual: stderr.slice(0, 200) }\n  }\n  return { ok: true }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the 'Usage: daemon-entry' stderr output as a stable contract: document it and add a test for it in the daemon entry's own test suite.","When refactoring the daemon entry's argv parser, search for the usage string in the verification script and update both together.","Avoid process.exit() before stderr drains in the no-args code path; use console.error followed by process.exit to ensure the line is captured."],"tags":["electron-packaging","daemon","argv-parsing","ci-gate","contract-drift"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}