fix(worker): connect tail WebSocket from the CLI, not the Worker server #338

Merged
gmackie merged 1 commit from fix/worker-tail-cli-ws into main 2026-08-14 18:59:26 +00:00
Owner

fg worker tail never worked — forgegraf.com is a CF Worker and cannot open the outbound tail wss. Server now mints the session only; the CLI connects the pre-authorized wss URL from Go (gorilla/websocket, trace-v1). Unblocks diagnosing runtime 500s (e.g. daily-dose).

🤖 Generated with Claude Code

`fg worker tail` never worked — forgegraf.com is a CF Worker and cannot open the outbound tail wss. Server now mints the session only; the CLI connects the pre-authorized wss URL from Go (gorilla/websocket, trace-v1). Unblocks diagnosing runtime 500s (e.g. daily-dose). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(worker): connect tail WebSocket from the CLI, not the Worker-hosted server
All checks were successful
CI / gitleaks (pull_request) Successful in 7s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 9m17s
00c2664a60
`fg worker tail` failed with `Fetch API cannot load: wss://tail.developers.workers.dev/…`:
forgegraf.com is itself a Cloudflare Worker, and Workers can't open an outbound
WebSocket to the CF tail endpoint via fetch. So the server-side tailWorker (which
did the Upgrade fetch) could never work.

Move the WS to the CLI (a real machine): the server now only MINTS the tail
session (createTailSession → POST /workers/scripts/<name>/tails, returns the
pre-authorized {id,url}); POST /api/fg/workers/<name>/tail returns {id,url,seconds,
probeUrl}; and `fg worker tail` connects the wss URL from Go (gorilla/websocket,
trace-v1 subprotocol — already vendored), fires the --url probes mid-window, reads
tail events for the window, and prints exceptions/logs. The session ends on WS
disconnect / CF expiry. Removes the dead server-side Upgrade-fetch + TailSocket shim.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gmackie scheduled this pull request to auto merge when all checks succeed 2026-08-14 18:50:19 +00:00
gmackie deleted branch fix/worker-tail-cli-ws 2026-08-14 18:59:27 +00:00
Sign in to join this conversation.
No description provided.