@devries-cameron20 / t3code-1 / commits / fd344d88ff
Fork 0

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

fix(tailscale): Serve setup fails when the tailnet has not enabled HTTPS (#35538)

Julius Marminge committed Nov 12, 2026 at 11:18 UTC fd344d88ffbbd21dbabe8672db4a1a39c2182c4f
3 files changed +56 -9
packages/tailscale/src/tailscale.test.ts
+24 -1
@@ -418,6 +418,29 @@ describe("tailscale", () => {
418 }),
419 );
420
421 + // regression: #35510 - without the https capability `tailscale serve` prints an
422 + // enablement notice, writes no Serve config, and still exits 0.
423 + it.effect("fails serve when the tailnet has not enabled HTTPS", () => {
424 + const layer = layerMockSpawner((_command, args) => {
425 + if (args[0] === "status") {
426 + return {
427 + stdout:
428 + '{"BackendState":"Running","Self":{"DNSName":"desktop.tail.ts.net.","CapMap":{}}}',
429 + };
430 + }
431 + if (args[1] === "status") return { stdout: "{}\n" };
432 + return { stdout: "\nYou don't have permission to enable this feature.\n" };
433 + });
434 +
435 + return Effect.gen(function* () {
436 + const exit = yield* ensureTailscaleServe({ localPort: 3773 }).pipe(
437 + Effect.provide(layer),
438 + Effect.exit,
439 + );
440 + assert.isTrue(Exit.isFailure(exit), "no Serve route was configured");
441 + });
442 + });
443 +
444 // regression: #21609 - without forceKillAfter a timed-out probe only gets
445 // SIGTERM, so a group member that ignores it outlives the call.
446 it.effect("escalates timed-out probes to SIGKILL", () => {
@@ -440,7 +463,7 @@ describe("tailscale", () => {
463 yield* readTailscaleStatus.pipe(Effect.provide(layer));
464 yield* readTailscaleSshEnabled.pipe(Effect.provide(layer));
465 yield* ensureTailscaleServe({ localPort: 45_678 }).pipe(Effect.provide(layer));
443 - assert.deepEqual(killGraces, [500, 500, 500]);
466 + assert.deepEqual(killGraces, [500, 500, 500, 500]);
467 });
468 });
469 });
packages/tailscale/src/tailscale.ts
+23 -4
@@ -450,16 +450,35 @@ const runTailscaleCommand = Effect.fn("tailscale.runTailscaleCommand")(function*
450 );
451 });
452
453 -export const ensureTailscaleServe = (input: {
453 +export class TailscaleServeHttpsDisabledError extends Schema.TaggedError<TailscaleServeHttpsDisabledError>()(
454 + "TailscaleServeHttpsDisabledError",
455 + {},
456 +) {
457 + override get message(): string {
458 + return "Tailscale Serve needs HTTPS enabled on the tailnet. Enable HTTPS certificates at https://login.tailscale.com/admin/dns.";
459 + }
460 +}
461 +
462 +export const ensureTailscaleServe = Effect.fn("tailscale.ensureTailscaleServe")(function* (input: {
463 readonly localPort: number;
464 readonly servePort?: number;
465 readonly localHost?: string;
457 -}): Effect.Effect<void, TailscaleCommandError, ChildProcessSpawner.ChildProcessSpawner> => {
466 +}): Effect.fn.Return<
467 + void,
468 + TailscaleCommandError | TailscaleServeHttpsDisabledError,
469 + ChildProcessSpawner.ChildProcessSpawner
470 +> {
471 + // Without the capability `tailscale serve` prints an enablement notice and exits 0, or blocks on
472 + // it, having configured nothing either way.
473 + const status = yield* Effect.option(readTailscaleStatus);
474 + if (Option.isSome(status) && status.value.httpsServeEnabled === false) {
475 + return yield* new TailscaleServeHttpsDisabledError();
476 + }
477 const servePort = input.servePort ?? DEFAULT_TAILSCALE_SERVE_PORT;
478 const localHost = input.localHost ?? "127.0.0.1";
479 const args = ["serve", "--bg", `--https=${servePort}`, `http://${localHost}:${input.localPort}`];
461 - return runTailscaleCommand(args, TAILSCALE_SERVE_TIMEOUT);
462 -};
480 + return yield* runTailscaleCommand(args, TAILSCALE_SERVE_TIMEOUT);
481 +});
482
483 /** A Serve route: a web handler at `mount` on `servePort`, or a TCP forward without one. */
484 export interface TailscaleServeRoute {
scripts/lib/dev-share.ts
+9 -4
@@ -6,6 +6,7 @@ import {
6 ensureTailscaleServe,
7 readTailscaleStatus,
8 type TailscaleCommandError,
9 + type TailscaleServeHttpsDisabledError,
10 type TailscaleStderrDiagnostic,
11 } from "@t3tools/tailscale";
12 import * as Effect from "effect/Effect";
@@ -21,10 +22,14 @@ const DIAGNOSTIC_EXPLANATIONS: Record<TailscaleStderrDiagnostic, string | undefi
22 unknown: undefined,
23 };
24
24 -const explainCommandFailure = (error: TailscaleCommandError): string | undefined =>
25 - error._tag === "TailscaleCommandExitError" && error.stderrDiagnostic !== undefined
26 - ? (DIAGNOSTIC_EXPLANATIONS[error.stderrDiagnostic] ?? "run the command by hand to see why")
27 - : undefined;
25 +const explainCommandFailure = (
26 + error: TailscaleCommandError | TailscaleServeHttpsDisabledError,
27 +): string | undefined =>
28 + error._tag === "TailscaleServeHttpsDisabledError"
29 + ? "HTTPS is not enabled on this tailnet — enable HTTPS certificates at https://login.tailscale.com/admin/dns"
30 + : error._tag === "TailscaleCommandExitError" && error.stderrDiagnostic !== undefined
31 + ? (DIAGNOSTIC_EXPLANATIONS[error.stderrDiagnostic] ?? "run the command by hand to see why")
32 + : undefined;
33
34 export class TailscaleUnavailableError extends Schema.TaggedError<TailscaleUnavailableError>()(
35 "TailscaleUnavailableError",