Skip to content

fix(runner): wake suspended children that were adopted after a daemon restart - #1021

Merged
Pizzaface merged 2 commits into
mainfrom
fix/adopted-child-wake
Nov 5, 2026
Merged

Pizzaface merged 2 commits into
mainfrom
fix/adopted-child-wake

Conversation

@Pizzaface

Copy link
Copy Markdown
Owner

Problem

Idle child sessions weren't woken by send_message input or session_complete followUps.

Runner log (Nov 5): adopted children logged idle child suspended — exiting worker but the daemon never logged suspending via IPC/exited. Every subsequent wake logged resuming session… + spawning headless worker… but never worker spawned, until the relay ended the session.

Root cause

Sessions adopted after a daemon restart sit in runningSessions with child: null and no IPC channel. When one suspends:

  1. pre_suspend IPC has nowhere to go, so suspending is never set.
  2. A suspend sends no session_ended, so the stale entry is never removed.
  3. The wake's spawnSession hits the entry; the deferred-wake path needs existing.suspending && existing.child, so it throws Session already running.
  4. doSpawn catches it and emits session_error with no log. The server's wake times out after 15s and the message is never delivered.

Children spawned by the current daemon were unaffected.

Fix

  • session-spawner.ts: a wake (isWake) replaces an adopted, child-less entry. The relay only wakes sessions it holds as suspended/offline, so the old worker is gone. Non-wake spawns still throw.
  • daemon.ts: log spawn failures instead of swallowing them.
  • Regression test: a plain spawn over an adopted entry still throws; a wake replaces it.

Verification

  • bun test packages/cli/src/runner/session-spawner.test.ts: 15/15 pass.
  • Typecheck clean for the touched files.

Adopted sessions (worker outlived a daemon restart) have no child handle or
IPC, so pre_suspend never reaches the daemon and a suspend sends no
session_ended. The stale child:null entry made the wake's spawnSession throw
'Session already running', swallowed silently by doSpawn — so messages and
followUps to idle children never woke them.

A wake now replaces an adopted, child-less entry (the relay only wakes
sessions it holds as suspended/offline). Non-wake spawns still throw.
Spawn failures are now logged.
@Pizzaface

Copy link
Copy Markdown
Owner Author

!pizza - fix the checks

@Pizzaface

Pizzaface commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner Author

Fixed in edf50f1: pinned the browser-dependent Unit Tests job to Ubuntu 24.04. ubuntu-latest had selected Ubuntu 26.04.1, unsupported by locked Playwright 1.58.2.

All 14 PR checks now pass on that commit: Unit Tests, Android, all five binary builds, runner-image check, both install-flow E2Es, and CodeQL checks. CI run 42083450647 completed successfully.

Local verification also passed: frozen install, lint, typecheck, build, full root tests against disposable Redis, workflow structure validation, and git diff --check. Full actionlint reports only existing E2E ShellCheck quote warnings reproduced on the original workflow.

@Pizzaface
Pizzaface merged commit 97fddbc into main Nov 5, 2026
14 checks passed
@Pizzaface
Pizzaface deleted the fix/adopted-child-wake branch November 5, 2026 18:30
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