Skip to content

fix(worker): log first local worker spawn failure and measure start time - #754

Open
anhnt256 wants to merge 2 commits into
DeadWaveWave:mainfrom
anhnt256:fix/722-first-spawn-failure-log
Open

anhnt256 wants to merge 2 commits into
DeadWaveWave:mainfrom
anhnt256:fix/722-first-spawn-failure-log

Conversation

@anhnt256

@anhnt256 anhnt256 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

💡 Change Scope

  • Small Change: Fast feedback, localized UI/logic, low-risk.
  • Large Change: New feature, cross-boundary logic, runtime-risk (persistence, IPC, lifecycle, recovery).

📝 What Does This PR Do?

Fixes #722

startLocalWorkerInternal retried a failed first Worker spawn without ever logging why the first attempt failed, so the Windows CI failure behind #717 left no line in the log. This change:

  • Logs the first spawn's failure before the retry, with its reason (ready timeout, exit code, or unreachable endpoint) and the elapsed time: Local worker first spawn failed after <N>ms (<reason>); retrying once.
  • Logs how long a successful first start takes: Local worker started in <N>ms.

The logging is unconditional console.warn/console.info (same pattern as the drain diagnostic in managedClaudeClearRuntime.ts), not the env-gated agent-launch diagnostics helper, so the line is present exactly in the no-diagnostics-flag situation that motivated #722. Retry behaviour and which error reaches the caller are unchanged.


🏗️ Large Change Spec (Required if "Large Change" is checked)

N/A (Small Change)


🔗 Co-change partners left untouched

  • src/app/worker/index.ts (with src/app/main/worker/localWorkerManager.ts, 7/9): the worker entry point only re-exports the spawn wiring; this change adds logging inside localWorkerManager.ts and does not alter the spawn contract, so no change is needed there.

✅ Delivery & Compliance Checklist

  • The local quick gate passes: pnpm verify:quick / pnpm pre-commit is green; any additional focused tests are reported above.
  • Full CI passes on the final revision before merge; local quick checks are not reported as full regression.

Verification (local, targeted): New tests/unit/app/localWorkerManager.firstSpawnFailure.spec.ts (3 tests): first failure is logged with reason + elapsed ms and the retry still runs; first failure is still logged when the retry also fails, and the retry's error is the one thrown; a successful first start logs its elapsed time. The new tests fail at base (3 failed) and pass with the fix (3 passed). Neighbouring worker-manager specs: 7 files, 33 passed; real-spawn integration spec localWorkerManager.stdout.spec.ts passes. tsc -b tsconfig.node.json tsconfig.web.json --noEmit, oxlint --max-warnings=0, and prettier --check on the changed files all pass. pnpm verify:quick was not run locally, so please rely on PR CI for the full gate.

Copy link
Copy Markdown
Owner

Thanks for making the first failure visible, @anhnt256. Could you cover the remaining part of #722 before we merge?

  • Log process spawn → receipt of the ready message separately from the endpoint health check. The current total includes both, but the 7.5 s limit applies only to the wait for ready.
  • Please share the spawn-to-ready timings from a few cold starts on Windows CI, along with the run/log link. Keep the 7.5 s timeout and retry behavior unchanged for now; let's judge them from those measurements.
  • Only say retrying once when a second spawn will actually happen. Shutdown or discovering a reusable connection can skip it. Please add a focused regression assertion for a path that skips the retry.

If the Windows measurements need to land separately, please change Fixes #722 to Part of #722 so the issue stays open.

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.

Local Worker start: the first spawn's failure is never logged, and the 7.5 s ready timeout is unmeasured

2 participants