Skip to content

fix(cli): preserve frontend output with bounded backpressure - #14886

Merged
tiborvass merged 1 commit into
mainfrom
codex/lossless-frontend-logs
Oct 29, 2026
Merged

tiborvass merged 1 commit into
mainfrom
codex/lossless-frontend-logs

Conversation

@tiborvass

@tiborvass tiborvass commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Large CLI output can fill the telemetry batch queue. The queue replaces older log records, so a listing can lose rows even when the command exits with code 0.

Use the existing engine/telemetry/BlockingLogProcessor for command stdout, stderr, and engine logs forwarded to the local frontend across CLI commands. Producers wait for queue space instead of losing records when the queue fills. Listings use the normal output path, without temporary files or deferred rendering.

Keep internal diagnostics best-effort. CLI telemetry setup routes ordinary slog.Warn/Error calls through a separate SDK batch processor to stderr. Consumer warnings, telemetry errors, and cleanup logs therefore cannot wait on the command output queue. No new slog API or changes to shared logging call sites are needed. Diagnostic delivery has a bounded shutdown wait and never closes stderr or the frontend.

Remote exporters retain their existing batch processors. The otel-go dependency is unchanged.

Give command EOF emission and local queue draining one independent 30-second deadline. Cancellation stops further batches and releases queued records. Exporter cleanup runs once, after its active export finishes. If local output cannot drain, report the failure through diagnostics, return a nonzero exit status, and skip final rendering. Pretty mode preserves cleanup errors and can exit without waiting for exporter EOF.

A slow frontend can delay producers. Internal diagnostics can be dropped under load or at exit. An exporter that never returns can leave background cleanup pending until process exit.

Validation: go build ./internal/cmd/dagger and git diff --check passed after rebasing onto main. One new CLI regression test covers full-queue EOF timeout, a failing exit status, and late exporter completion. Tests were not run for this revision.

@tiborvass
tiborvass force-pushed the codex/lossless-frontend-logs branch from 6f316e6 to b18c057 Compare October 27, 2026 17:13
@tiborvass
tiborvass force-pushed the codex/lossless-frontend-logs branch from 868dac9 to b3d6b7b Compare October 28, 2026 15:44
tiborvass added a commit that referenced this pull request Oct 28, 2026
Squash all changes from #14886 through b3d6b7b, including its otel-go dependency and nested module pins.
@tiborvass
tiborvass marked this pull request as ready for review October 28, 2026 18:11
@tiborvass
tiborvass force-pushed the codex/lossless-frontend-logs branch 2 times, most recently from 03396b9 to bc6ecb3 Compare October 28, 2026 19:18
@tiborvass tiborvass changed the title fix(cli): preserve frontend output with bounded backpressure fix(cli): deliver artifact listings through local output files Oct 28, 2026
tiborvass added a commit that referenced this pull request Oct 28, 2026
Squash all changes from #14886 through b3d6b7b, including its otel-go dependency and nested module pins.
@tiborvass tiborvass changed the title fix(cli): deliver artifact listings through local output files fix(cli): render listings after frontend shutdown Oct 28, 2026
@tiborvass
tiborvass force-pushed the codex/lossless-frontend-logs branch from ce9303f to cfeb253 Compare October 28, 2026 20:53
tiborvass added a commit that referenced this pull request Oct 28, 2026
Squash all changes from #14886 through b3d6b7b, including its otel-go dependency and nested module pins.
@tiborvass tiborvass changed the title fix(cli): render listings after frontend shutdown fix(cli): apply backpressure to frontend log delivery Oct 28, 2026
@tiborvass
tiborvass force-pushed the codex/lossless-frontend-logs branch from cfeb253 to 03915a9 Compare October 28, 2026 21:34
@tiborvass tiborvass changed the title fix(cli): apply backpressure to frontend log delivery fix(cli): preserve frontend logs with bounded backpressure Oct 28, 2026
@tiborvass
tiborvass force-pushed the codex/lossless-frontend-logs branch 5 times, most recently from 34bc008 to f07056d Compare October 28, 2026 22:33
@tiborvass tiborvass changed the title fix(cli): preserve frontend logs with bounded backpressure fix(cli): preserve frontend output with bounded backpressure Oct 29, 2026
@tiborvass
tiborvass force-pushed the codex/lossless-frontend-logs branch from f07056d to 277ee58 Compare October 29, 2026 07:16
Large CLI output can fill the telemetry batch queue and silently lose rows while the command exits successfully.

Use BlockingLogProcessor for command stdio and engine logs forwarded to the local frontend across CLI commands. Route default slog diagnostics through a separate SDK batch processor that writes to stderr, so consumer warnings and cleanup logs cannot wait on the command output queue. Keep this routing private to CLI telemetry setup and leave remote exporters best-effort.

Give EOF emission and local queue draining one independent shutdown deadline. Stop new batches after cancellation, release queued records, and serialize exporter cleanup after its active export. Return local drain failures as command errors and skip final rendering instead of waiting on a blocked exporter. Preserve pretty frontend cleanup errors and do not wait for EOF after a failed drain.

Keep one CLI regression covering full-queue EOF timeout, a failing exit status, and late exporter completion. Tests were not run for this revision.

Signed-off-by: Tibor Vass <[email protected]>
@tiborvass
tiborvass force-pushed the codex/lossless-frontend-logs branch from 277ee58 to 8ec37a8 Compare October 29, 2026 07:21
@tiborvass
tiborvass merged commit 935c75f into main Oct 29, 2026
93 checks passed
@tiborvass
tiborvass deleted the codex/lossless-frontend-logs branch October 29, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants