fix: queue worker termination when not yet connected to hub #121

Merged
jonas.hanisch merged 1 commit from fix/120-worker-termination-busy-check into main 2026-01-24 11:26:52 +00:00
Owner

Problem

When terminating a worker that wasn't yet connected to the WorkerHub (connectedWorkerId = undefined), the busy-check was completely skipped and the worker was immediately killed - even if it was actively processing a task.

// Before: Bug - this check was skipped when hubWorkerId was undefined
if (hubWorkerId && this.deps.workerHub.isWorkerBusy(hubWorkerId)) {
  // queue termination
}
// Worker was killed immediately if no hubWorkerId!

Solution

Added safety check: If a worker has status: 'running' but no hub connection yet, queue the termination instead of killing immediately.

// After: Safe - queue termination if worker is running but not connected
if (!hubWorkerId && spawnedWorker.status === 'running') {
  this.deps.workerProcessManager.queueTermination(id);
  return { queued: true, reason: 'Worker not yet connected to hub' };
}

Test Plan

  • Start a worker
  • Immediately try to terminate before it connects to hub
  • Verify termination is queued, not immediate
  • Verify worker terminates gracefully after connecting

Fixes #120

🤖 Generated with Claude Code

## Problem When terminating a worker that wasn't yet connected to the WorkerHub (`connectedWorkerId = undefined`), the busy-check was completely skipped and the worker was immediately killed - even if it was actively processing a task. ```typescript // Before: Bug - this check was skipped when hubWorkerId was undefined if (hubWorkerId && this.deps.workerHub.isWorkerBusy(hubWorkerId)) { // queue termination } // Worker was killed immediately if no hubWorkerId! ``` ## Solution Added safety check: If a worker has `status: 'running'` but no hub connection yet, queue the termination instead of killing immediately. ```typescript // After: Safe - queue termination if worker is running but not connected if (!hubWorkerId && spawnedWorker.status === 'running') { this.deps.workerProcessManager.queueTermination(id); return { queued: true, reason: 'Worker not yet connected to hub' }; } ``` ## Test Plan - [ ] Start a worker - [ ] Immediately try to terminate before it connects to hub - [ ] Verify termination is queued, not immediate - [ ] Verify worker terminates gracefully after connecting Fixes #120 🤖 Generated with [Claude Code](https://claude.ai/code)
fix: queue worker termination when not yet connected to hub
All checks were successful
CI / check (pull_request) Successful in 0s
CI / build (pull_request) Successful in 41s
CI / validate-plugin (pull_request) Successful in 34s
fa2a0c7159
Previously, when terminating a worker that wasn't yet connected to the
WorkerHub (connectedWorkerId = undefined), the busy-check was skipped
and the worker was immediately killed - even if it was processing a task.

Now, if a worker has status 'running' but no hub connection yet, the
termination is queued for safety instead of killing immediately.

Fixes #120

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
jonas.hanisch force-pushed fix/120-worker-termination-busy-check from fa2a0c7159
All checks were successful
CI / check (pull_request) Successful in 0s
CI / build (pull_request) Successful in 41s
CI / validate-plugin (pull_request) Successful in 34s
to 5af36519dc
All checks were successful
CI / check (pull_request) Successful in 1s
CI / build (pull_request) Successful in 1m19s
CI / validate-plugin (pull_request) Successful in 1m6s
2026-01-24 10:39:31 +00:00
Compare
jonas.hanisch force-pushed fix/120-worker-termination-busy-check from 5af36519dc
All checks were successful
CI / check (pull_request) Successful in 1s
CI / build (pull_request) Successful in 1m19s
CI / validate-plugin (pull_request) Successful in 1m6s
to 90f7a71290
All checks were successful
CI / check (pull_request) Successful in 0s
CI / build (pull_request) Successful in 34s
CI / validate-plugin (pull_request) Successful in 28s
2026-01-24 11:25:12 +00:00
Compare
jonas.hanisch deleted branch fix/120-worker-termination-busy-check 2026-01-24 11:26:52 +00:00
Sign in to join this conversation.
No description provided.