Skip to content

[Bug]: Tailscale Serve reload still fails with 502/CSS preload on macOS in 0.1.12 #42770

Not planned

Description

@usedhonda

Follow-up to #36409. Its startup retry was merged in #26451, but the Mac mini/Tailscale Serve connection resets still reproduce on stable 0.1.12.

Area

apps/web, apps/server (headless packaged server via Tailscale Serve)

Steps to reproduce

  1. Run the packaged T3 Code server on Apple silicon macOS, bound to loopback, and expose it on a private HTTPS port with Tailscale Serve.
  2. Open its web app in Chrome on another Mac over the same tailnet.
  3. Use Chrome's normal Reload button on an existing draft. It can display the startup error even though the previous load rendered the draft.

Expected

Normal reload opens the same draft reliably without manual hard reloads.

Actual

On 0.1.12 the browser displayed Unable to preload CSS for /assets/main-DYJdcEdq.css. In that same second, the Tailscale system extension logged 49 reset errors on the loopback connection to the T3 server. A later individual request for the exact CSS through the same HTTPS endpoint returned 200. The T3 process did not need to restart for the asset to become reachable.

Environment

Relevant log (sanitized)

HTTP 502 on static assets
Unable to preload CSS for /assets/main-DYJdcEdq.css
http: proxy error: dial tcp 127.0.0.1:3773: connect: connection reset by peer

Suggest tracking the remaining startup request burst separately from the retry behavior. #36427 is a related unmerged reduction in startup JS requests; this report is a real macOS/Tailscale reproduction on the stable build.

Local mitigation (not an upstream fix)

A loopback-only shim on the existing private Serve origin handles only /assets, keeping application and WebSocket routing direct. It reuses at most 24 connections to T3. At a larger test size this initially moved some resets to the shim's listener (278 HTTP 200 / 22 HTTP 502). After raising only the shim job's file-descriptor allowance, the same 300 static requests on one HTTP/2 connection returned 300 HTTP 200 in one run. No system TCP setting or T3 authentication change was involved. The experiments do not establish which local kernel/resource limit triggered the original burst.

Activity

  1. juliusmarminge commented on Nov 25, 2026

    @juliusmarminge
    Member

    I tried to reproduce this on the current build and could not.

    Commit f99eceb (origin/main) and the published v0.1.12 darwin-arm64 CLI archive, on a pool Mac (macOS 26, Apple silicon, kern.ipc.somaxconn=128). (1) Built apps/web on main and ran T3CODE_DEV_SEED=0 node apps/server/src/bin.ts serve --port <p> --host 127.0.0.1 --base-dir <fresh>. (2) Unpacked t3-0.1.12-darwin-arm64.tar.gz and ran t3 serve on loopback with a fresh base dir. (3) Put each behind an HTTPS/HTTP2 reverse proxy that dials a fresh TCP connection to the backend per request (as Tailscale Serve's Go proxy does), and drove headless Chromium via Playwright: fresh loads, then normal page.reload() in one context. Findings: the 0.1.12 client/ has no .vite/manifest.json, and the server serves /assets/main-DYJdcEdq.css (the exact file in the report) with cache-control: no-cache, while main's source build serves the same kind of asset public, max-age=31536000, immutable. Requests per load through the proxy: 0.1.12 first load 234, every normal reload 232-233 (5/5); main build first load about 232, reloads 7-12 (10/10). So on released builds every normal reload re-sends the full startup burst. The final symptom (502 / connection reset / 'Unable to preload CSS' boot error) did not appear: 0 dial errors and 0 boot errors across 22 loads, and even 1000 synchronous TCP connects to the idle server were all accepted (listen queue 0/0/128). Overflowing the queue likely needs real Tailscale Serve and a busy server, which were not available.

    Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.

  2. spa5k commented on Nov 26, 2026

    @spa5k

    Still reproduces on 0.1.12 stable. Here is a repro against real Tailscale Serve that doesn't need a browser.

    Setup: T3 Code desktop 0.1.12 stable, macOS 27.2.1 on Apple silicon, server on 127.0.0.1:3773. Tailscale Standalone 1.104.7, tailscale serve HTTPS :44441 -> http://127.0.0.1:3773. Clients: a Safari 27.2 Dock web app and Helium (Chromium) on another Mac on the same tailnet.

    Browser symptom: "T3 Code failed to start / TypeError: Importing a module script failed" on nearly every launch. A Chromium HAR shows 49 /assets/*.js responses and 1 CSS response as 502 with an empty body (content-length: 0) from the Serve endpoint. The other 172 assets were 200.

    Repro (run on the host, curl 8.7.1): all 413 JS assets referenced by the entry and main chunks, fetched in parallel:

    target concurrency result
    Serve HTTPS, HTTP/2 20 413 × 200
    Serve HTTPS, HTTP/2 100 413 × 200
    Serve HTTPS, HTTP/2 200 226 × 200, 187 × 502
    Serve HTTPS, HTTP/2 300 219 × 200, 194 × 502
    127.0.0.1:3773 direct 200 / 400 413 × 200
    # urls.cfg holds lines of:  url = https://<host>.ts.net:44441/assets/<chunk>.js  /  output = /dev/null
    curl -sS --http2 -Z --parallel-max 200 -K urls.cfg -w '%{http_code}\n' | sort | uniq -c

    The results vary between runs: one run at 200 had only 5 × 502. Failures always started somewhere between 100 and 200 concurrent requests.

    This doesn't look like listen-queue overflow, at least here: netstat -s -p tcp reports 0 listen queue overflow (and 0 embryonic connection dropped) both before and after the failing runs, with kern.ipc.somaxconn = 128. Direct loopback handles 400 concurrent connections without errors. The failure seems to be in Serve's proxy path once there are roughly 200+ concurrent upstream requests. That matches your finding that a generic proxy doesn't reproduce it.

    Why it happens on every launch: 0.1.12 serves the hashed /assets/* files with cache-control: no-cache and a weak ETag, so every launch revalidates the full burst of about 400 requests (the server log here shows mostly 304s). Your note that main already serves public, max-age=31536000, immutable should fix repeat loads once it's released. First loads will still hit the burst, and so will new devices and Safari Dock web apps (they have separate storage from Safari). Capping concurrent module preloads or bundling fewer startup chunks would cover those cases.

    The single automatic reload from #26451 doesn't help much here: with this many requests failing, the retry rarely gets every startup chunk either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions