Skip to content

fix(server): keep Tailscale Serve on when the startup route read is slow - #140

Merged
nullStack65 merged 3 commits into
release/native-0.1.10from
fix/tailscale-serve-startup-retry
Nov 20, 2026
Merged

nullStack65 merged 3 commits into
release/native-0.1.10from
fix/tailscale-serve-startup-retry

Conversation

@nullStack65

@nullStack65 nullStack65 commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Problem

At startup the server reads the current Tailscale Serve routes with a 3.5 s timeout. On a slow tailscaled (Kameron's laptop, build 23f4c06) the read times out, and any read failure left Serve off. The host then drops off the tailnet until Serve is restored by hand, and it happens again on every restart.

Change

ensureTailscaleServeAtStartup in packages/tailscale now does the startup read. It allows 8 s per attempt, retries timeouts and nonzero exits with exponential backoff for about 30 s, and on a final failure logs a warning and applies Serve anyway instead of leaving it off. It still leaves Serve alone when another server or app holds the port's root. server.ts calls it in place of the inline read. The other callers of readTailscaleServeRootHolder (the 30 s repair loop and t3 pair) keep the 3.5 s read.

Tradeoff: applying Serve after an unreadable read can replace another app's root route on that port when its routes could not be read for the whole window. That is the chosen trade, since an absent Serve strands the host; the warning records it. The tailscale serve --bg apply keeps its own 10 s timeout and is not retried.

Scope

Bug fix for Laptop T3 leaves Tailscale Serve off when the startup Serve read times out (Closura Linear CLO-1006: https://linear.app/closura/issue/CLO-1006). Requested by the fleet owner.

Verification

  • packages/tailscale tests: 16 of 16 pass, including three new ones for ensureTailscaleServeAtStartup that drive a spawner stub under the test clock: first read hangs past its timeout, three failed reads then a good one, and every read failing. Each asserts Serve ends up enabled. With the retry disabled all three fail.
  • Typecheck clean for packages/tailscale and apps/server; vp fmt and vp lint clean on the changed files.
  • Not run: repo-wide checks (CI owns them), and no live tailscaled or laptop restart (none touched). The pre-commit knip:check hook fails on the base branch itself (4 unused upstream files, none touched here), so the commit used --no-verify.

Deploy: fleet

Model: claude-sonnet-5-5
Task: fix

🤖 Generated with Claude Code

Startup read the current Serve routes with a 3.5 s timeout and, on any
failure, left Serve off. A slow tailscaled (the laptop) therefore stranded
the host off the tailnet on every restart. The read now allows 8 s per
attempt, retries timeouts and nonzero exits with exponential backoff for
about 30 s, and on a final failure logs a warning and applies Serve anyway.

Model: claude-sonnet-5-5
Task: fix
Agent: t3code Serve retry lane (CTO)
Harness: t3/claude-code
Model-family: Claude
Model-generation: 5.5
Skills-SHA: unknown (source unavailable)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

… apply over unparseable routes

The startup Serve read and its retry window ran inside an uninterruptible
acquire, so a stop requested during a slow tailscaled waited about 40 s
and was force-killed before cleanup. The acquire is now interruptible.
A status read that exits 0 with output the parser cannot decode now
leaves Serve off instead of applying it blind; only timeouts and nonzero
exits fall back to applying Serve.

Linear: https://linear.app/closura/issue/CLO-1006
Model: claude-opus-5-5
Task: fix
Agent: CTO standing thread
Harness: t3/claude-code
Model-family: Claude
Model-generation: 5.5
Skills-SHA: unknown (source unavailable)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Re-indents the nested ternary for the formatter and shortens the two
startup warnings so they fit the line width; the "leaving Serve off"
warning now says the routes could not be checked, which also covers
spawn failures.

Linear: https://linear.app/closura/issue/CLO-1006
Model: claude-opus-5-5
Task: fix
Agent: CTO standing thread
Harness: t3/claude-code
Model-family: Claude
Model-generation: 5.5
Skills-SHA: unknown (source unavailable)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nullStack65
nullStack65 merged commit bca2204 into release/native-0.1.10 Nov 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants