cloudflare / cloudflare/sandbox-sdk

createOpencodeServer hangs when configured with OPENCODE_SERVER_PASSWORD

Open
#853 1 comment 0 reactions 1 assignee Claimed by @ghostwriternr View on GitHub
bug
Dominant language
TypeScript
Stars
1.1k
Forks
114
Avg merge
22h 42m
Merged PRs (30d)
14

Description

**Describe the bug**
When `OPENCODE_SERVER_PASSWORD` is set as env key-value pair in `createOpenCodeServer`. Then it hangs until it reaches the configured `OPENCODE_STARTUP_TIMEOUT_MS` duration.
The resulting server post-timeout is however completely valid for use with `proxyToOpencode` and exists after ~10s post `createOpenCodeServer` execution.

**To Reproduce**
Steps to reproduce the behavior:
1. Setup the [opencode example](https://github.com/cloudflare/sandbox-sdk/tree/main/examples/opencode)
2. Adapt the `createOpencodeServer` execution of `src/index.ts` such that it's executed like below:
```
const server = await createOpencodeServer(sandbox, {
directory: '/home/user/agents',
config: getConfig(),
// Optional: Pass custom environment variables (e.g., for tracing/telemetry)
// env: { TRACEPARENT: '00-abc123-def456-01' },
env: {
OPENCODE_SERVER_PASSWORD: 'password'
}
});
```
4. Start the application through `npm run dev`
5. Navigate to the app location in your browser

**Expected behavior**
After a few seconds the user is prompted for an username and password by the browser (username: 'opencode', password: 'password') and then redirected to the chat interface.

**Current behavior**
The page keeps loading for 3 minutes after which the user is prompted for an username and password (username: 'opencode', password: 'password') and is then redirected to the chat interface.

**Screenshots**
N/A

**Environment**
- `@cloudflare/sandbox`: 0.12.4
- `wrangler`: 4.118.0

**Additional context**
Through additional loggings I was able to discover that the `/path` calls which `startOpenCodeServer` waits for keeps throwing a 401 status code while the `waitForPort` logic is waiting for a 200 code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.