You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ProcessOutput.json() parses combined stdout+stderr, breaking on CLIs that log progress to stderr #1505
ProcessOutput.json() runs JSON.parse on the combined output (stdall), not on stdout. Well-behaved CLIs write JSON to stdout and progress/prompts to stderr, so the stderr output gets mixed in and json() throws even though stdout contains valid JSON.
We hit this in Wasp, where we orchestrate the Railway CLI with its --json flag: railway add --json prints the JSON result to stdout but echoes the prompt answers to stderr, so .json() broke unexpectedly. We had to resort to parsing stdout ourselves with JSON.parse(output.stdout): wasp-lang/wasp#4711
How it should work?
json() should parse stdout only. If the combined behavior is intentional, it would help to document which stream json() reads and offer a stdout-only variant e.g. json({ source: 'stdout' })
How to reproduce the bug?
import{$}from'zx'constout=await$({quiet: true})`node -e "console.error('progress...'); console.log('{\\"ok\\":true}')"`JSON.parse(out.stdout)// { ok: true }out.json()// SyntaxError: Unexpected token 'p', "progress.."... is not valid JSON
changed the title [-][Bug]: ProcessOutput.json() parses combined stdout+stderr, breaking on CLIs that log progress to stderr[/-][+]`ProcessOutput.json()` parses combined stdout+stderr, breaking on CLIs that log progress to stderr[/+]on Aug 19, 2026
Hi @florian-vassilev @antongolub — I have opened PR #1511 with a fix for this issue. It makes json() parse stdout by default (falling back to stdall when stdout is empty for full backward compatibility), and optionally accepts an explicit source argument ('stdout' | 'stderr' | 'stdall'). Unit tests and docs have been added as well.
Activity
[-][Bug]: ProcessOutput.json() parses combined stdout+stderr, breaking on CLIs that log progress to stderr[/-][+]`ProcessOutput.json()` parses combined stdout+stderr, breaking on CLIs that log progress to stderr[/+]shubhransh-gupta commentedon Sep 4, 2026
Hi @florian-vassilev @antongolub — I have opened PR #1511 with a fix for this issue. It makes
json()parsestdoutby default (falling back tostdallwhen stdout is empty for full backward compatibility), and optionally accepts an explicitsourceargument ('stdout' | 'stderr' | 'stdall'). Unit tests and docs have been added as well.fix(core): parse stdout in json() (google#1505)
fix(core): allow stream selection in json() defaulting to stdout (goo…
feat(core): support source option in json() and fallback stdout to st…
antonmedv commentedon Oct 6, 2026
@antongolub I think this one maybe worth considering. WDYT?