Start the `SpritesSandbox` command `timeout` once its exec socket is open
- Closes #8932
The Sprites backend started a command's timeout before opening its exec socket, so handshake time and the 1 s and 4 s retry sleeps used it up. With the fake transport, a slow handshake made run(['echo', 'ok'], timeout=60) raise WorkspaceTimeoutError with no output.
This starts the deadline once the socket is open. The command cannot start before then, because the wrapper waits for stdin EOF, so handshake time is not command time. Each handshake attempt now has its own 10 s bound (_HANDSHAKE_TIMEOUT, websockets' default open_timeout), so three stalled attempts give up after about 35 s and raise NetworkError, the same error as any other failed handshake. Before, a stalled handshake raised WorkspaceTimeoutError once the command's timeout ran out.
Unlike Modal and E2B, whose timeout includes the exec-start call, Sprites now excludes it. Those backends make one start call; Sprites retries it with backoff, which a short timeout could not survive.
_timed_out no longer checks for a socket that never opened: the deadline cannot fire before it opens.
Tests:
test_the_command_timeout_starts_once_the_exec_socket_is_open: a 0.5 s handshake andtimeout=0.3now return the output. It fails onmain.test_a_stalled_handshake_fails_after_its_retries: replacestest_timeout_during_a_stalled_handshake_reads_no_capture, which pinned the old behaviour. Three stalled attempts raiseNetworkErrorand run nothing.test_only_the_handshake_bound_applies_while_the_exec_socket_opens: the bound in force while the socket opens is the handshake's, not the command's 60 s.
No Sprites key was available, so this is proven with the repo's fake Sprites transport only.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.