How to debug server (worker) code? #6488

Open
opened 2026-02-16 18:04:22 -05:00 by yindo · 1 comment
Owner

Originally created by @linchen1987 on GitHub (Jan 16, 2026).

Originally assigned to: @jayair on GitHub.

Question

I can debug TUI code in two ways:

1 bun run --cwd packages/opencode --conditions=browser --inspect src/index.ts

--------------------- Bun Inspector ---------------------
Listening:
  ws://localhost:6499/arzcsfu03h5
Inspect in browser:
  https://debug.bun.sh/#localhost:6499/arzcsfu03h5
--------------------- Bun Inspector ---------------------

2 bun run --cwd packages/opencode --conditions=browser src/index.ts in "JavaScript Debug Terminal" in VsCode

Image

However, I don't know how to debug the code in worker.js (/packages/opencode/src/cli/cmd/tui/worker.ts) because the server runs in a separate thread.

What's the recommended method for debugging the server code?

Originally created by @linchen1987 on GitHub (Jan 16, 2026). Originally assigned to: @jayair on GitHub. ### Question I can debug TUI code in two ways: 1 `bun run --cwd packages/opencode --conditions=browser --inspect src/index.ts` ```sh --------------------- Bun Inspector --------------------- Listening: ws://localhost:6499/arzcsfu03h5 Inspect in browser: https://debug.bun.sh/#localhost:6499/arzcsfu03h5 --------------------- Bun Inspector --------------------- ``` 2 `bun run --cwd packages/opencode --conditions=browser src/index.ts` in "JavaScript Debug Terminal" in VsCode <img width="2100" height="868" alt="Image" src="https://github.com/user-attachments/assets/6c4bd9c0-df9e-41b1-9b55-72ff4526184d" /> However, I don't know how to debug the code in worker.js (`/packages/opencode/src/cli/cmd/tui/worker.ts`) because the server runs in a separate thread. What's the recommended method for debugging the server code?
yindo added the docs label 2026-02-16 18:04:22 -05:00
Author
Owner

@linchen1987 commented on GitHub (Jan 17, 2026):

I found a solution to debug server code:

run bun run --cwd packages/opencode --conditions=browser src/index.ts serve --port 4096 --cors in "JavaScript Debug Terminal" in VsCode

bun run --cwd packages/opencode --conditions=browser src/index.ts serve --port 4096 --cors
Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.
opencode server listening on http://127.0.0.1:4096

then use web ui in browser ( http://127.0.0.1:4096 ) as frontend

@linchen1987 commented on GitHub (Jan 17, 2026): I found a solution to debug server code: run `bun run --cwd packages/opencode --conditions=browser src/index.ts serve --port 4096 --cors` in "JavaScript Debug Terminal" in VsCode ``` bun run --cwd packages/opencode --conditions=browser src/index.ts serve --port 4096 --cors Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured. opencode server listening on http://127.0.0.1:4096 ``` then use web ui in browser ( http://127.0.0.1:4096 ) as frontend
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6488