Skip to content

fix: preserve context for rendering and report encoder errors - #788

Merged
andrinoff merged 1 commit into
charmbracelet:mainfrom
gudcks:codex/fix-render-context
Sep 24, 2026
Merged

andrinoff merged 1 commit into
charmbracelet:mainfrom
gudcks:codex/fix-render-context

Conversation

@gudcks

@gudcks gudcks commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #787.

Recording teardown canceled the context subsequently passed to ffmpeg, so completed tapes could exit successfully without creating their output. Keep recording cancellation on a child context and use the caller's context for rendering. Return encoder errors instead of only logging their output, so a missing ffmpeg executable or a failed render reaches the caller.

Added a regression test for missing ffmpeg and an opt-in browser test that records a short tape, decodes the resulting GIF, and checks cancellation immediately before rendering. All three cases failed on the original code and pass with the fix.

Validation on macOS arm64:

  • go test -race ./...
  • go vet ./...
  • VHS_TEST_BROWSER=1 go test -run 'Test(RenderMissingFFmpeg|EvaluateGIF)$' -count=1 -v . (real Chrome, ttyd and ffmpeg)

Implemented with OpenAI Codex assistance and independently reviewed with Codex before submission.

@andrinoff andrinoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

Comment thread vhs.go
out, err := cmd.CombinedOutput()
if err != nil {
log.Println(string(out))
return fmt.Errorf("render failed: %w", err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning on the first failed encoder means if the GIF fails, the MP4/WebM/screenshots for the same tape are never attempted. Consider collecting the errors with errors.Join and running all commands

@andrinoff
andrinoff merged commit 87b2f37 into charmbracelet:main Sep 24, 2026
8 checks passed
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.

v0.12.0 exits 0 and writes no output file on ubuntu-24.04 runners; v0.11.0 records the same tape

2 participants

⌂ 换网址