fix(host-service): stop polling a workspace whose git reads keep timing out

KI
6d ago
+153-3

Problem

A user's host-service log showed git/readWorkspaceRefs timing out at its 15 s worker budget 170 times, plus 25 more at 30 s. That task runs local git only (config, rev-parse, remote get-url), and the budget starts at dispatch, so plain git was taking over 15 s on that machine. Every timeout still cost a worker slot for the full 15 s and left a git process behind, and the PR runtime kept scheduling the same workspace again on the next watcher event and the 5 min sweep. On a host already slow to exec, that is load stacked on the process carrying terminal I/O.

Change

  • WorkerTaskRunner tags a budget expiry: the rejection now carries code: WORKER_TASK_TIMEOUT (isWorkerTaskTimeout exported). The message is unchanged.
  • PullRequestRuntimeManager.syncWorkspaceRow tracks consecutive timeouts per workspace. After two in a row the workspace sits out its branch sync for 5 min, doubling per further timeout up to 1 h. Any successful read clears the streak. Non-timeout git failures behave as before.
  • Logged once per cooldown: git is not answering for a workspace; pausing its branch sync for Nm.

Both the watcher path and the 5 min sweep go through syncWorkspaceRow, so both are covered.

Testing

  • New tests: two timeouts start the cooldown and later polls never reach git, the window doubles after the next timeout, a success clears it; a non-timeout failure never starts one. The cooldown test was checked to fail with the check disabled.
  • bun test src/runtime/pull-requests (63 pass), bun test src/workers (14 pass), bun run typecheck, biome clean.

https://claude.ai/code/session_01UWyngsh3WSdEM6kmf1P8s5


Summary by cubic

Stops re-polling a workspace whose git reads keep timing out. Previously each timeout cost a worker slot for the full 15-second budget and the watcher plus 5-minute sweep kept rescheduling the same workspace; now after two consecutive timeouts the workspace pauses its branch sync for a window that doubles from 5 minutes up to an hour, and a successful read clears the streak.

Bug Fixes

  • Worker timeout rejections now carry code: WORKER_TASK_TIMEOUT; isWorkerTaskTimeout identifies them.
  • Non-timeout git failures still behave as before.

Summary by CodeRabbit

  • Bug Fixes

    • Improved pull request synchronization resilience when workspace branch reads repeatedly time out.
    • Automatically pauses affected synchronization briefly after repeated timeouts, with progressively longer cooldowns up to one hour.
    • Resumes normal synchronization after a successful read.
    • Non-timeout errors continue to be handled without triggering the cooldown behavior.
  • Tests

    • Added coverage for timeout cooldowns, recovery, and non-timeout failures.