-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
Problem
Every request fails with:
Error proxying request to container <id>: Error: The container is not running, consider calling start()
Root Cause
The sandbox middleware in src/index.ts calls getSandbox() to get the sandbox instance but never calls sandbox.start() before setting it in the Hono context:
// Current (broken)
const sandbox = getSandbox(c.env.Sandbox, 'moltbot', options);
c.set('sandbox', sandbox);When a subsequent handler calls sandbox.containerFetch() or sandbox.wsConnect(), the container hasn't been booted yet, causing the error.
Fix
Add await sandbox.start() before setting the sandbox in context:
const sandbox = getSandbox(c.env.Sandbox, 'moltbot', options);
await sandbox.start();
c.set('sandbox', sandbox);start() is idempotent — it is a no-op if the container is already running, so calling it on every request is safe.
Steps to Reproduce
- Deploy the worker to Cloudflare
- Make any request to the worker URL
- Observe the 500 error and the "container is not running" log in Workers observability
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels