Problem
The sandbox Process object can have status 'starting' before transitioning to 'running'. Several polling loops only check for 'running':
src/gateway/utils.ts — waitForProcess:
while (proc.status === 'running' && attempts < maxAttempts) {
src/gateway/r2.ts — isR2Mounted:
while (proc.status === 'running' && attempts < 10) {
If the first poll happens while the process is still in 'starting' state, the loop exits immediately. getLogs() then returns empty output, and exitCode is null/undefined.
This causes:
isR2Mounted returning false even when R2 is mounted (mount check process hasn't run yet)
waitForProcess returning before the process has actually completed
- Downstream failures like "Failed to mount R2 storage" on the Backup Now button
Fix
Include 'starting' in the polling condition:
while ((proc.status === 'running' || proc.status === 'starting') && attempts < maxAttempts) {
Testing
Deployed and verified — R2 mount checks and sync operations work reliably after the fix. Previously, Backup Now would intermittently fail with "Failed to mount R2 storage".
Co-authored with Claude Code (Opus 4.6).