Skip to content

fix: harden worker lifecycle concurrency and cleanup#30

Merged
jaredjakacky merged 3 commits into
mainfrom
fix/lifecycle-race-hardening
Jun 19, 2026
Merged

fix: harden worker lifecycle concurrency and cleanup#30
jaredjakacky merged 3 commits into
mainfrom
fix/lifecycle-race-hardening

Conversation

@jaredjakacky

Copy link
Copy Markdown
Owner

Summary

Hardens Workerkit lifecycle behavior against several semantic races involving startup, loop shutdown, command completion, and concurrent lifecycle operations.

Changes

  • Preserve asynchronous failures reported during worker startup.
  • Scope WorkerRuntime handles and commands to lifecycle generations.
  • Prevent stale callbacks from mutating restarted workers.
  • Serialize lifecycle operations while keeping command dispatch concurrent.
  • Prevent duplicate loops after timed-out stops.
  • Ensure loop failures are published before stop completion.
  • Coordinate loop cleanup hooks across concurrent and repeated stops.
  • Preserve stopped lifecycle when in-flight commands fail or panic late.
  • Make observer test helpers safe for concurrent callbacks.
  • Clarify direct Stop, graceful shutdown, and observer contracts.
  • Fix cleanup being skipped after a LoopWorker restart fails during its start hook.

No new exported APIs, packages, or dependencies are introduced.

Verification

  • make verify
  • make test-race
  • go vet ./...
  • Full repository race tests with shuffle across 20 runs
  • Core race tests with shuffle across 100 runs
  • Focused LoopWorker race tests across 100 runs
  • govulncheck reports no vulnerabilities

@jaredjakacky jaredjakacky merged commit 5eda50f into main Jun 19, 2026
7 checks passed
@jaredjakacky jaredjakacky deleted the fix/lifecycle-race-hardening branch June 19, 2026 21:39
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