🤖 fix: waitForAgentReport keeps its waiter when onExecutionStarted throws synchronously

Open Beginner friendly
#7,794 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Start with TaskService.waitForAgentReport and the timer-arming path through startReportWaitTimeout. Then find the existing tests for this wait and add the case where onExecutionStarted throws synchronously. Done means the wait settles and its waiter and foreground-await count are cleaned up.

Written by the indexing model from the issue text.

Description

If the onExecutionStarted callback passed to TaskService.waitForAgentReport throws synchronously, the wait rejects but its waiter and the requester's foreground-await count stay registered.

Cause

The callback runs from the timer arming (startReportWaitTimeout after the stack-16 split; inline before it). A synchronous throw leaves that step before the timer is set, so the waiter's cleanup never runs. The async rejection of the callback is already caught (.catch), but a synchronous throw is not.

Effect

The same as the leak fixed in #7764: the requester stays counted as foreground-awaiting, so countActiveAgentTasks skips it and the queue can start more tasks than maxParallelAgentTasks allows. A dead waiter also stays registered.

Likelihood

Low. The only production caller that passes the callback is WorkflowRunner, and its callback does not throw in practice.

Fix

Wrap the call so a synchronous throw is treated like a rejection (cleanup, then settle), and add a test that passes a throwing callback.

Found by the stack-16 advisor (TaskService plan 8). The code existed before the split; the split moved it unchanged.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $546.28

Dominant language
TypeScript
Stars
2.1k
Forks
139
Avg merge
3h 34m
Merged PRs (30d)
951

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from coder/xum

All issues in coder/xum

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.