You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Shell: a command that ends just as its timeout passes is reported as moved to the background #63747
Since #63699, a foreground shell call still running at its timeout is moved to the background (Effect.timeoutOption on jobs.block, then shell.timeout(id, 0)).
There is a race: if the command exits between the timeout firing and the move, the call returns the "moved to the background" result, and the real result arrives later as a background notice, although the command had already finished in the foreground.
Expected: when the command has already settled by the time the move happens, the call returns its normal foreground result (output and exit code) and no background notice follows.
In our fork we move the job only while it is still running (jobs.background(id, { running: true }) is a no-op once it has settled), and the call then reads the settled result. Happy to send a PR.
Not observed; this looks likely from reading the code.
Thanks for the precise report. I confirmed this by reading the code on the latest dev (46aefe3). I did not catch it happening in a run.
In packages/core/src/tool/plugin/shell.ts, when the foreground jobs.block wait times out, any info returned by jobs.background(job.id) is treated as "moved to the background". The call then runs shell.timeout(id, 0) and notifyWhenDone.
In packages/core/src/job.ts, Job.background skips a settled job only when it has no recovery. Shell jobs are always started with recovery, so a command that settles between the timeout firing and the move is still marked as backgrounded. The call then returns the background result, and the real output arrives later as a notice.
I also drove dev from source with a simulated model making parallel foreground sleep ~1s calls with timeout: 1000. Commands near the boundary were reported as moved to the background and then completed shortly after. From outside I could not tell which of them had already exited before the move, so that run does not prove the race on its own.
Only running the job move while the command is still running, as you describe, matches how the code reads. A maintainer will look at it.
Activity
opencodejr commentedon Nov 13, 2026
Not observed; this looks likely from reading the code.
Thanks for the precise report. I confirmed this by reading the code on the latest
dev(46aefe3). I did not catch it happening in a run.packages/core/src/tool/plugin/shell.ts, when the foregroundjobs.blockwait times out, any info returned byjobs.background(job.id)is treated as "moved to the background". The call then runsshell.timeout(id, 0)andnotifyWhenDone.packages/core/src/job.ts,Job.backgroundskips a settled job only when it has norecovery. Shell jobs are always started withrecovery, so a command that settles between the timeout firing and the move is still marked as backgrounded. The call then returns the background result, and the real output arrives later as a notice.I also drove
devfrom source with a simulated model making parallel foregroundsleep ~1scalls withtimeout: 1000. Commands near the boundary were reported as moved to the background and then completed shortly after. From outside I could not tell which of them had already exited before the move, so that run does not prove the race on its own.Only running the job move while the command is still running, as you describe, matches how the code reads. A maintainer will look at it.