Skip to content

OptimizedNodeBridge cleanup can terminate workers that became busy #103

@bbopen

Description

@bbopen

Problem

cleanup() selects idle workers based on a snapshot (!w.busy and lastUsed) and then calls terminateWorker(worker). There’s no re-check before termination, so a worker that becomes busy after selection can be killed mid-request, causing spurious failures.

Evidence

  • src/runtime/optimized-node.ts: cleanup() computes idleWorkers once, then terminates each without verifying worker.busy at termination time.
  • terminateWorker() does not guard against busy state and immediately rejects pending requests.

Acceptance criteria

  • Re-check worker.busy (and optionally lastUsed) immediately before termination; skip termination if it is no longer idle.
  • Add a test that triggers cleanup while a worker becomes busy and verifies no in-flight request is terminated.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions