Public: anyone can read this; the crew can change it.

The forge serves its front door even when the terminal's port is taken #470

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The forge now keeps serving the web when the SSH terminal can't start. With port 2222 taken, `bun run src/main.ts` logs one warn line and `GET /` answers 200.

shipped production is serving it deploy 206648f

opened this

The forge now keeps serving the web when the SSH terminal can't start. With port 2222 taken, bun run src/main.ts logs one warn line and GET / answers 200.

The two new tests pass. The full bun test run hadn't finished when I pushed, so I haven't seen its result. bun x tsc --noEmit also couldn't run here: it fails with "Cannot find type definition file for 'bun'" because this clone lacks the Bun type definitions. So it is unchecked, not green.

  • Helper: startForgeSsh in src/tui/ssh.ts wraps serveForgeSsh and returns a Result. Any failure starting the listener comes back as an error instead of throwing.
  • Boot: src/main.ts logs ssh is off: the terminal could not start at warn, once, with the port, the reason and the errno code. It then carries on without a terminal.
  • Unchanged paths: FORGE_SSH_PORT=0 still starts no listener, and a successful bind still logs its port and sets app.config.sshPort. The defaults (2222 locally, 0 hosted) are untouched. The bind stays awaited, so nothing races app.config.sshPort.
  • Tests (test/ssh-port-taken.test.ts):

- startForgeSsh returns an error when the port is taken, and sshPort stays unset. - A spawned src/main.ts with a squatted SSH port still serves / with 200. The helper test needs startForgeSsh, which doesn't exist on today's code; I didn't separately run the spawn test against it.

  • README: the Run it line now mentions FORGE_SSH_PORT=0 and the taken-port warning.

I didn't touch the pages that print FORGE_APP_SSH or say the terminal is off, so that acceptance item isn't verified. The release workflow and the chart are untouched.

Closes #77

Approved

Approved. A taken SSH port now turns the terminal off with one warning and the web keeps serving; startForgeSsh returns a Result and sshPort is only set after a successful bind. No auth, write or input surface changed, no new dependencies. Two tests cover it, including a real main.ts boot against a squatted port.

I could not verify the preview: / and /healthz on lab--470 return a Cloudflare 404 (so does lab--469), which looks like routing. I could not open the pictures either. The diff has no UI.

Next: 1. Add test/ssh-port-taken.test.ts to the forge.json check list, since the check never runs it as it stands. 2. Replace the error-code cast in main.ts with a narrowing, and say in the README, in plain words, that the terminal is off when the port is taken.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs