@devries-cameron20 / t3code-1 / commits / 639ac5ec77
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): explain a disabled tailnet Serve instead of timing out (#10958)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>

Seth committed Oct 19, 2026 at 22:47 UTC 639ac5ec77e65871fa1df64d64d85cc28ed42694
5 files changed +96
apps/desktop/src/backend/tailscaleEndpointProvider.test.ts
+1
@@ -209,6 +209,7 @@ describe("tailscale endpoint provider", () => {
209 return {
210 magicDnsName: "desktop.tail.ts.net",
211 tailnetIpv4Addresses: ["100.74.126.34"],
212 + httpsServeEnabled: null,
213 };
214 }),
215 });
apps/server/src/cli/pair.test.ts
+55
@@ -11,8 +11,11 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
11 import { assert, describe, expect, it } from "@effect/vitest";
12 import * as Effect from "effect/Effect";
13 import * as Layer from "effect/Layer";
14 +import * as Sink from "effect/Sink";
15 +import * as Stream from "effect/Stream";
16 import * as TestConsole from "effect/testing/TestConsole";
17 import { Command, CliError } from "effect/cli";
18 +import { ChildProcessSpawner } from "effect/process";
19
20 import { cli } from "../binCli.ts";
21 import {
@@ -318,6 +321,58 @@ describe("t3 pair", () => {
321 assert.include(rendered, "No running T3 Code server found.");
322 }).pipe(Effect.provide(NodeServices.layer)),
323 );
324 +
325 + // Without the capability `tailscale serve` blocks on an enablement URL, so
326 + // pairing must stop at status instead of spawning it.
327 + it.effect("explains a tailnet without HTTPS serve instead of running tailscale serve", () =>
328 + withDescriptorServer((origin) =>
329 + Effect.gen(function* () {
330 + const baseDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-pair-ts-test-"));
331 + yield* persistServerRuntimeState({
332 + path: NodePath.join(baseDir, "userdata", "server-runtime.json"),
333 + state: yield* makePersistedServerRuntimeState({
334 + config: { host: "127.0.0.1", devUrl: undefined },
335 + port: Number(new URL(origin).port),
336 + }),
337 + });
338 + const tailscaleCalls: Array<ReadonlyArray<string>> = [];
339 + const spawner = ChildProcessSpawner.make((command) => {
340 + const { args } = command as unknown as { readonly args: ReadonlyArray<string> };
341 + tailscaleCalls.push(args);
342 + const stdout =
343 + args[0] === "status"
344 + ? `{"Self":{"DNSName":"pair-test.invalid.","CapMap":{"funnel":null}}}`
345 + : "";
346 + return Effect.succeed(
347 + ChildProcessSpawner.makeHandle({
348 + pid: ChildProcessSpawner.ProcessId(1),
349 + exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(args[0] === "status" ? 0 : 1)),
350 + isRunning: Effect.succeed(false),
351 + kill: () => Effect.void,
352 + unref: Effect.succeed(Effect.void),
353 + stdin: Sink.drain,
354 + stdout: Stream.make(new TextEncoder().encode(stdout)),
355 + stderr: Stream.empty,
356 + all: Stream.empty,
357 + getInputFd: () => Sink.drain,
358 + getOutputFd: () => Stream.empty,
359 + }),
360 + );
361 + });
362 +
363 + const error = yield* provideCliTestLayers(
364 + runCli(["pair", "--base-dir", baseDir, "--tailscale"]).pipe(
365 + Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
366 + Effect.flip,
367 + ),
368 + );
369 +
370 + assert.include(String(error), "Tailscale Serve is not enabled on your tailnet.");
371 + assert.include(String(error), "https://login.tailscale.com/admin/dns");
372 + assert.deepEqual(tailscaleCalls, [["status", "--json"]]);
373 + }),
374 + ).pipe(Effect.provide(NodeServices.layer)),
375 + );
376 });
377
378 describe("auth scope options", () => {
apps/server/src/cli/pair.ts
+14
@@ -90,6 +90,15 @@ export class MagicDnsNameMissingError extends Schema.TaggedError<MagicDnsNameMis
90 }
91 }
92
93 +export class TailscaleServeNotEnabledError extends Schema.TaggedError<TailscaleServeNotEnabledError>()(
94 + "TailscaleServeNotEnabledError",
95 + {},
96 +) {
97 + override get message(): string {
98 + return "Tailscale Serve is not enabled on your tailnet. Enable HTTPS certificates at https://login.tailscale.com/admin/dns, then run this command again.";
99 + }
100 +}
101 +
102 export class ServesOtherEnvironmentError extends Schema.TaggedError<ServesOtherEnvironmentError>()(
103 "ServesOtherEnvironmentError",
104 { servePort: Schema.Number },
@@ -346,6 +355,11 @@ const resolveTailscalePairingBase = Effect.fn("pair.resolveTailscalePairingBase"
355 if (status.magicDnsName === null) {
356 return yield* new MagicDnsNameMissingError();
357 }
358 + // Without the capability `tailscale serve` blocks on an enablement URL
359 + // until it times out, which names neither the setting nor where to change it.
360 + if (status.httpsServeEnabled === false) {
361 + return yield* new TailscaleServeNotEnabledError();
362 + }
363 const baseUrl = buildTailscaleHttpsBaseUrl({
364 magicDnsName: status.magicDnsName,
365 servePort: input.servePort,
packages/tailscale/src/tailscale.test.ts
+14
@@ -142,10 +142,23 @@ describe("tailscale", () => {
142 assert.deepEqual(status, {
143 magicDnsName: "desktop.tail.ts.net",
144 tailnetIpv4Addresses: ["100.100.100.100"],
145 + httpsServeEnabled: null,
146 });
147 }),
148 );
149
150 + it.effect("reads the HTTPS serve capability from the status capability map", () =>
151 + Effect.gen(function* () {
152 + const enabled = yield* parseTailscaleStatus(
153 + `{"Self":{"CapMap":{"https":null,"funnel":null}}}`,
154 + );
155 + assert.equal(enabled.httpsServeEnabled, true);
156 +
157 + const disabled = yield* parseTailscaleStatus(`{"Self":{"CapMap":{"funnel":null}}}`);
158 + assert.equal(disabled.httpsServeEnabled, false);
159 + }),
160 + );
161 +
162 it.effect("preserves status decoding failures without exposing cause text", () =>
163 Effect.gen(function* () {
164 const error = yield* parseTailscaleStatus("{not-json").pipe(Effect.flip);
@@ -203,6 +216,7 @@ describe("tailscale", () => {
216 assert.deepEqual(status, {
217 magicDnsName: "desktop.tail.ts.net",
218 tailnetIpv4Addresses: ["100.90.1.2"],
219 + httpsServeEnabled: null,
220 });
221 });
222 });
packages/tailscale/src/tailscale.ts
+12
@@ -125,6 +125,7 @@ export class TailscaleStatusParseError extends Schema.TaggedError<TailscaleStatu
125 const TailscaleStatusSelf = Schema.Struct({
126 DNSName: Schema.optional(Schema.Unknown),
127 TailscaleIPs: Schema.optional(Schema.Unknown),
128 + CapMap: Schema.optional(Schema.Unknown),
129 });
130
131 const TailscaleStatusJson = Schema.Struct({
@@ -136,6 +137,12 @@ export type TailscaleStatusJson = typeof TailscaleStatusJson.Type;
137 export interface TailscaleStatus {
138 readonly magicDnsName: string | null;
139 readonly tailnetIpv4Addresses: readonly string[];
140 + /**
141 + * `tailscale serve --https` needs the `https` capability, which the control
142 + * plane grants once the tailnet enables HTTPS certificates. `null` when the
143 + * CLI reports no capability map (older CLI), so callers still attempt serve.
144 + */
145 + readonly httpsServeEnabled: boolean | null;
146 }
147
148 const collectStdout = <E>(stream: Stream.Stream<Uint8Array, E>): Effect.Effect<string, E> =>
@@ -203,9 +210,14 @@ export const parseTailscaleStatus = (
210 }
211 }
212
213 + const capMap = parsed.Self?.CapMap;
214 return {
215 magicDnsName: normalizeMagicDnsName(parsed),
216 tailnetIpv4Addresses,
217 + httpsServeEnabled:
218 + typeof capMap === "object" && capMap !== null && !Array.isArray(capMap)
219 + ? Object.hasOwn(capMap, "https")
220 + : null,
221 };
222 }),
223 );