Skip to content

fix: batch PR status fetching to prevent memory spikes#101

Merged
bborn merged 1 commit intomainfrom
fix/batch-pr-fetching
Jan 10, 2026
Merged

fix: batch PR status fetching to prevent memory spikes#101
bborn merged 1 commit intomainfrom
fix/batch-pr-fetching

Conversation

@bborn
Copy link
Copy Markdown
Owner

@bborn bborn commented Jan 10, 2026

Summary

  • Fix memory spikes caused by spawning too many gh and git processes
  • Previously spawned N processes per tick for N tasks; now spawns M processes per 30 seconds for M repos
  • Add FetchAllPRsForRepo() for batch PR fetching via single gh pr list call
  • Replace per-task PR fetching with batch refreshAllPRs() on 30-second timer
  • Also makes --host, --port, --local flags persistent for subcommands

Test plan

  • Run tasks -l and monitor memory usage - should see no more spikes of multiple gh processes
  • Verify PR status still updates in kanban view (within 30 seconds)
  • Verify merged PRs are still detected

🤖 Generated with Claude Code

Previously, the app was spawning processes for every task on every tick:
- loadTasks() spawned goroutines calling CheckPRStateAndUpdateTask for
  each task with a branch (doing git fetch + PR checks) every 1 second
- fetchAllPRInfo() spawned separate `gh pr view` calls for every task
  when cache expired (every 30 seconds)

With 10+ tasks, this caused bursts of 10+ gh processes (~40MB each)
plus git fetch calls, leading to memory spikes that could exhaust
system memory and cause Claude instances to OOM.

Changes:
- Add FetchAllPRsForRepo() that fetches all PRs for a repo in a single
  `gh pr list` call instead of N individual `gh pr view` calls
- Replace per-task PR fetching with batch refreshAllPRs() that groups
  tasks by repo and fetches sequentially (avoiding memory spikes)
- Add dedicated 30-second prRefreshTick instead of checking on every tick
- Remove per-task CheckPRStateAndUpdateTask goroutine spam from loadTasks()

Also: make --host, --port, --local flags persistent so they work on subcommands

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@bborn bborn merged commit 5154aa1 into main Jan 10, 2026
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.

1 participant