Skip to content

fix(cloud): claw creation modal hangs during provisioning #2648

@verse-mycelium

Description

@verse-mycelium

Bug

When clicking "Create" in the create claw modal, the modal hangs for a long time waiting for the API to return. The modal eventually closes but drops back to the org page with stale cache — the new claw doesn't appear until several hard refreshes, at which point it shows in "provisioning" state.

Expected

Click "Create" → modal closes instantly → claw appears in the list with status "provisioning".

Root Cause (Initial Analysis)

createClawHandler in cloud/api/claws.handlers.ts does everything synchronously in one Effect pipeline:

  1. DB insert (fast)
  2. R2 bucket provisioning via clawDeployment.provision() (slow — Cloudflare API)
  3. Secret encryption + DB update (fast)
  4. Container warm-up via clawDeployment.warmUp() (slow — cold start)

Steps 2 and 4 are the bottleneck. The API doesn't return until the entire pipeline completes, keeping the modal spinner alive.

Proposed Approach

Split into fast path (return immediately) and background work:

  • Fast path: DB insert → return claw with status "provisioning" → modal closes
  • Background: R2 provisioning → encrypt secrets → DB update → warm-up (fire-and-forget or via queue)

Also: the frontend should invalidate the claws query cache after creation so the new claw appears immediately.

Files

  • cloud/api/claws.handlers.tscreateClawHandler
  • cloud/app/components/create-claw-modal.tsx — frontend modal
  • cloud/claws/deployment/ — provisioning service

Reported by Dandelion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions