{"record":{"id":"a9b702baab5b7157","repo":"can1357/oh-my-pi","slug":"full-stderr-capture-must-be-requested-when-spawnin","errorCode":null,"errorMessage":"Full stderr capture must be requested when spawning the process (pass stderr: \"full\")","messagePattern":"Full stderr capture must be requested when spawning the process \\(pass stderr: \"full\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/utils/src/ptree.ts","lineNumber":499,"sourceCode":"\tasync json(): Promise<unknown> {\n\t\treturn JSON.parse(new TextDecoder().decode(await this.#readOutputBytes()));\n\t}\n\n\tasync arrayBuffer(): Promise<ArrayBuffer> {\n\t\treturn (await this.#readOutputBytes()).buffer as ArrayBuffer;\n\t}\n\n\tasync bytes(): Promise<Uint8Array> {\n\t\treturn this.#readOutputBytes();\n\t}\n\n\t// ── Wait ─────────────────────────────────────────────────────────────\n\n\tasync wait(opts?: WaitOptions): Promise<ExecResult> {\n\t\tconst { allowNonZero = false, allowAbort = false, stderr: stderrMode = \"buffer\" } = opts ?? {};\n\t\tconst stderrChunks = this.#stderrChunks;\n\t\tif (stderrMode === \"full\" && !stderrChunks) {\n\t\t\tthrow new Error('Full stderr capture must be requested when spawning the process (pass stderr: \"full\")');\n\t\t}\n\n\t\tconst stdoutP = this.#readStream(this.proc.stdout);\n\t\tconst stderrP =\n\t\t\tstderrMode === \"full\" && stderrChunks\n\t\t\t\t? this.#stderrDone.then(() => new TextDecoder().decode(Buffer.concat(stderrChunks)))\n\t\t\t\t: this.#stderrDone.then(() => this.#stderrTail);\n\n\t\tconst [stdout, stderr] = await Promise.all([stdoutP, stderrP]);\n\n\t\tlet exitError: Exception | undefined;\n\t\ttry {\n\t\t\tawait this.#exited;\n\t\t} catch (err) {\n\t\t\tif (err instanceof Exception) exitError = err;\n\t\t\telse throw err;\n\t\t}\n\t\tthis.#clearTimeout();","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ptree.ts#L481-L517","documentation":"ExecResult.wait({ stderr: \"full\" }) requires that full stderr buffering was requested at spawn time. If the process was spawned without stderr capture, the data is gone by the time wait() runs, so the library throws this mismatch error instead of returning empty output.","triggerScenarios":"Calling `await proc.wait({ stderr: \"full\" })` (or helpers defaulting to stderrMode \"full\") on a process spawned without `stderr: \"full\"` — the internal #stderrChunks buffer is undefined.","commonSituations":"Copy-pasting wait options onto an existing spawn helper; a helper upgraded to return full stderr without updating the spawn call; defaults changing between library versions.","solutions":["Pass `stderr: \"full\"` in the spawn options when creating the process.","Use `stderr: \"buffer\"` (default) in wait() if full capture is not needed.","Check which spawn wrapper created the process and align its stderr option with the wait call."],"exampleFix":"// before\nconst proc = spawn(cmd, { stdout: \"pipe\", stderr: \"pipe\" });\nawait proc.wait({ stderr: \"full\" });\n// after\nconst proc = spawn(cmd, { stdout: \"pipe\", stderr: \"full\" });\nawait proc.wait({ stderr: \"full\" });","handlingStrategy":"validation","validationCode":"if (wantsFullStderr) {\n  // at spawn time\n  spawn(cmd, { stdout: 'pipe', stderr: 'full' });\n}","typeGuard":null,"tryCatchPattern":"try {\n  const res = await proc.wait({ stderr: 'full' });\n} catch (err) {\n  if (String(err.message).includes('stderr: \\\"full\\\"')) {\n    throw new Error('spawn the process with stderr: \"full\" to use this wait mode');\n  } else throw err;\n}","preventionTips":["Keep spawn options and wait options in the same helper so they can't drift.","Grep for wait({ stderr: 'full' }) call sites whenever changing spawn defaults.","Prefer the default 'buffer' mode unless full stderr is genuinely required."],"tags":["subprocess","api-misuse","stderr"],"backgroundTag":"api-option-mismatch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}