fix(sandbox): prevent Daytona heartbeat sleep leak#910
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a560034f73
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ' if kill -0 "$bf_pid" 2>/dev/null; then', | ||
| " bf_heartbeat_elapsed=0", | ||
| ' while [ ! -e "$bf_stop" ] && kill -0 "$bf_pid" 2>/dev/null; do', | ||
| " sleep 1", |
There was a problem hiding this comment.
Stop waiting a full poll tick after the child exits
On Daytona DinD execs with timeout_sec >= 600, this sleep 1 keeps the wrapper process alive until the next poll even after wait "$bf_pid" has observed the real command exit. _compose_exec passes the same timeout_sec down to _sandbox_exec, which wraps the whole compose command in GNU timeout {timeout_sec}; timeout --help says it kills a command that is still running after the duration and exits 124. As a result, a command that succeeds near the deadline, e.g. at 599.5s for a 600s verifier/agent timeout, can be killed before cat "$bf_out" and exit "$bf_rc", turning a successful run into a timeout and dropping its output.
Useful? React with 👍 / 👎.
Summary
sleep 60orphaned with captured pipes openRoot cause
The fast-command path could send
TERMafter the heartbeat shell spawnedsleep 60but before it stored the child PID. The trap then exited without killing the sleep process. That orphan retained stdout/stderr, sosubprocess.run(..., timeout=2)timed out even though the parent shell had already returned 0.Validation
uv run pytest -q tests/test_daytona_dind_compose_up.py— 12 passeduv run ruff format --check src tests toolsuv run ruff check src tests toolsuv run ty checkuv lock --checkuv run python -m pytest tests/ -q— 4835 passed, 8 skipped, 7 deselectedpip-audit— no known vulnerabilities, one documented ignore