Skip to content

fix(Runner): add timeout for cache warmup and use posix_kill instead of exit#141

Merged
s2x merged 1 commit intomasterfrom
fix/140-runner-hangs-with-empty-cache
Apr 15, 2026
Merged

fix(Runner): add timeout for cache warmup and use posix_kill instead of exit#141
s2x merged 1 commit intomasterfrom
fix/140-runner-hangs-with-empty-cache

Conversation

@s2x
Copy link
Copy Markdown
Collaborator

@s2x s2x commented Apr 14, 2026

Summary

Fixes #140 - Runner hangs indefinitely when cache is empty.

Problem

When the cache was empty, Runner::run() would fork a child process to warm up the cache. However:

  1. Using exit() in the child caused deadlock with extensions like grpc that register shutdown handlers
  2. There was no timeout mechanism - if something went wrong during warmup, the parent would wait forever

Solution

  1. Add 30 second timeout for cache warmup with clear error message
  2. Use posix_kill(getmypid(), SIGKILL) instead of exit() to avoid deadlock
  3. Handle SIGKILL properly - recognize it as expected exit when child kills itself
  4. Throw descriptive RuntimeException on timeout

Testing

  • All 293 tests pass
  • phpstan no errors
  • php-cs-fixer no issues
  • rector no issues

@s2x s2x force-pushed the fix/140-runner-hangs-with-empty-cache branch 2 times, most recently from eaa269a to 16bcb29 Compare April 14, 2026 21:10
…of exit

- Add CACHE_WARMUP_TIMEOUT constant (30 seconds) for cache warmup
- Use posix_kill(getmypid(), SIGKILL) for success, SIGTERM for error
  to avoid deadlock with extensions that register shutdown handlers (e.g., grpc)
- Handle SIGKILL (9) as success, SIGTERM (15) as error
- Throw RuntimeException with clear message on timeout or error
- Add tests for SIGKILL success, SIGTERM error, and timeout behavior

Fixes #140
@s2x s2x force-pushed the fix/140-runner-hangs-with-empty-cache branch from 16bcb29 to abe4829 Compare April 15, 2026 07:02
@s2x s2x merged commit f12980a into master Apr 15, 2026
22 checks passed
@s2x s2x deleted the fix/140-runner-hangs-with-empty-cache branch April 15, 2026 07:04
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.

Runner hangs indefinitely when cache is empty - needs timeout/failure handling

1 participant