Skip to content

waitForProcess and isR2Mounted don't account for 'starting' process status #229

@cindyrui71

Description

@cindyrui71

Problem

The sandbox Process object can have status 'starting' before transitioning to 'running'. Several polling loops only check for 'running':

src/gateway/utils.tswaitForProcess:

while (proc.status === 'running' && attempts < maxAttempts) {

src/gateway/r2.tsisR2Mounted:

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions