Skip to content

fix(ui): initialize state selectively to prevent background task conflicts#2773

Merged
tusharmath merged 3 commits intomainfrom
join-handle-fix
Apr 1, 2026
Merged

fix(ui): initialize state selectively to prevent background task conflicts#2773
tusharmath merged 3 commits intomainfrom
join-handle-fix

Conversation

@tusharmath
Copy link
Copy Markdown
Collaborator

@tusharmath tusharmath commented Apr 1, 2026

Summary

Fix "JoinHandle polled after completion" panics caused by background tasks spawned during forge info racing with process exit.

Context

When running forge info, the handler was calling on_new() to initialize the model/agent state. However, on_new() also internally invokes hydrate_caches(), which spawns fire-and-forget background tasks. Because forge info exits quickly after printing output, these background tasks would still be running (or just completing) as the process terminated, triggering JoinHandle polled after completion panics in the async runtime.

The info command only needs agent/provider/model resolution — it has no use for the cache hydration side effects.

Changes

  • Replaced on_new() call with init_state(false) in the TopLevelCommand::Info handler
  • init_state(false) performs only the necessary state initialization without spawning background cache hydration tasks

Testing

# Run the info command and verify no panics occur
cargo run -- info

# Run with a specific conversation ID if applicable
cargo run -- info --conversation-id <id>

# Run the test suite for forge_main
cargo insta test --accept -p forge_main

Links

  • Related: background task lifecycle management in UI::on_new() / UI::hydrate_caches()

@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Apr 1, 2026
@tusharmath tusharmath changed the title join handle fix fix(ui): initialize state selectively to prevent background task conflicts Apr 1, 2026
@tusharmath tusharmath enabled auto-merge (squash) April 1, 2026 18:19
@tusharmath tusharmath merged commit e37bbb9 into main Apr 1, 2026
9 checks passed
@tusharmath tusharmath deleted the join-handle-fix branch April 1, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant