{"record":{"id":"d5ff59faaf3e86c9","repo":"can1357/oh-my-pi","slug":"missing-supervised-command","errorCode":null,"errorMessage":"missing supervised command","messagePattern":"missing supervised command","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/utils/src/ptree.ts","lineNumber":54,"sourceCode":"\t\t\t\targs: [FFIType.i32, FFIType.u64, FFIType.u64, FFIType.u64, FFIType.u64],\n\t\t\t\treturns: FFIType.i32,\n\t\t\t},\n\t\t\twaitpid: {\n\t\t\t\targs: [FFIType.i32, FFIType.ptr, FFIType.i32],\n\t\t\t\treturns: FFIType.i32,\n\t\t\t},\n\t\t});\n\t\tbreak;\n\t} catch {}\n}\nif (!libc) throw new Error(\"failed to load libc for Linux child supervision\");\n\nif (libc.symbols.prctl(36, 1, 0, 0, 0) !== 0) {\n\tthrow new Error(\"failed to become a Linux child subreaper\");\n}\n\nconst commandJson = Bun.env.${LINUX_SUBREAPER_COMMAND_ENV};\nif (!commandJson) throw new Error(\"missing supervised command\");\nconst callerBunBeBun = Bun.env.${LINUX_SUBREAPER_BUN_BE_BUN_ENV};\ndelete Bun.env.${LINUX_SUBREAPER_COMMAND_ENV};\ndelete Bun.env.${LINUX_SUBREAPER_BUN_BE_BUN_ENV};\nif (callerBunBeBun === undefined) delete Bun.env.BUN_BE_BUN;\nelse Bun.env.BUN_BE_BUN = callerBunBeBun;\nconst command = JSON.parse(commandJson);\nconst child = Bun.spawn(command, {\n\tstdin: \"inherit\",\n\tstdout: \"pipe\",\n\tstderr: \"pipe\",\n\twindowsHide: true,\n\tenv: Bun.env,\n});\n\nasync function relay(stream, destination) {\n\tconst writer = destination.writer();\n\tfor await (const chunk of stream) writer.write(chunk);\n\tawait writer.flush();","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ptree.ts#L36-L72","documentation":"Inside the generated Linux subreaper worker script, the supervised command is passed via the OMP_PTREE_SUBREAPER_COMMAND environment variable as JSON. This error is thrown when that variable is unset or empty at worker startup, meaning the worker was started without a command to supervise.","triggerScenarios":"The subreaper worker process is spawned but the OMP_PTREE_SUBREAPER_COMMAND env var was not set (or was cleared) before spawning — e.g. the worker script is executed manually, an env-sanitizing wrapper strips unknown OMP_* variables, or the parent's env passing is broken.","commonSituations":"Manually re-running the worker script for debugging, environments that whitelist env vars (CI, systemd with EnvironmentFile sanitization), or tools that scrub 'unrecognized' variables from child environments.","solutions":["Ensure the worker is spawned by ptree itself, which sets OMP_PTREE_SUBREAPER_COMMAND; don't launch the generated script manually.","Check env-var sanitization layers (systemd, CI, wrappers) and whitelist the OMP_PTREE_SUBREAPER_* variables.","If reproducing manually, export OMP_PTREE_SUBREAPER_COMMAND to a JSON array like '[\"echo\",\"hi\"]'."],"exampleFix":"// before (manual run, no env)\nbun worker.ts\n// after\nOMP_PTREE_SUBREAPER_COMMAND='[\"sleep\",\"10\"]' bun worker.ts","handlingStrategy":"validation","validationCode":"if (!process.env.OMP_PTREE_SUBREAPER_COMMAND) {\n  throw new Error('OMP_PTREE_SUBREAPER_COMMAND must be set before launching the subreaper worker');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always spawn the subreaper worker through ptree's API, never manually.","Whitelist OMP_PTREE_* variables in any env-sanitizing layer (systemd, CI).","Log the child's env keys in debug mode when debugging worker startup."],"tags":["linux","env-var","subprocess"],"backgroundTag":"missing-env-var","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}