@devries-cameron20 / t3code-1 / commits / 9c19aa9160
Fork 0

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

fix(tailscale): serve setup no longer times out on a long success summary (#34743)

Julius Marminge committed Nov 11, 2026 at 20:37 UTC 9c19aa91600dfa786efab32e68c20a7dcd88e988
2 files changed +50 -2
packages/tailscale/src/tailscale.test.ts
+43
@@ -1,9 +1,13 @@
1 import { assert, describe, it } from "@effect/vitest";
2 +import * as Deferred from "effect/Deferred";
3 import * as Duration from "effect/Duration";
4 import * as Effect from "effect/Effect";
5 +import * as Exit from "effect/Exit";
6 +import * as Fiber from "effect/Fiber";
7 import * as Layer from "effect/Layer";
8 import * as Sink from "effect/Sink";
9 import * as Stream from "effect/Stream";
10 +import * as TestClock from "effect/testing/TestClock";
11 import { ChildProcessSpawner } from "effect/process";
12 import * as HostProcess from "@t3tools/shared/HostProcess";
13
@@ -317,6 +321,45 @@ describe("tailscale", () => {
321 });
322 });
323
324 + // regression: #34736 - a full stdout pipe blocks the child before it exits.
325 + it.effect("drains serve stdout so a long success summary does not time out", () =>
326 + Effect.gen(function* () {
327 + const stdoutDrained = yield* Deferred.make<void>();
328 + const layer = layerSpawner(
329 + ChildProcessSpawner.make(() =>
330 + Effect.succeed(
331 + ChildProcessSpawner.makeHandle({
332 + pid: ChildProcessSpawner.ProcessId(1),
333 + exitCode: Deferred.await(stdoutDrained).pipe(
334 + Effect.as(ChildProcessSpawner.ExitCode(0)),
335 + ),
336 + isRunning: Effect.succeed(true),
337 + kill: () => Effect.void,
338 + unref: Effect.succeed(Effect.void),
339 + stdin: Sink.drain,
340 + stdout: Stream.make(encoder.encode("https://example.ts.net/\n")).pipe(
341 + Stream.ensuring(Deferred.succeed(stdoutDrained, undefined)),
342 + ),
343 + stderr: Stream.empty,
344 + all: Stream.empty,
345 + getInputFd: () => Sink.drain,
346 + getOutputFd: () => Stream.empty,
347 + }),
348 + ),
349 + ),
350 + );
351 +
352 + const fiber = yield* ensureTailscaleServe({ localPort: 3773 }).pipe(
353 + Effect.provide(layer),
354 + Effect.exit,
355 + Effect.forkChild,
356 + );
357 + yield* TestClock.adjust("11 seconds");
358 + const exit = yield* Fiber.join(fiber);
359 + assert.isTrue(Exit.isSuccess(exit), String(exit));
360 + }),
361 + );
362 +
363 // regression: #21609 - without forceKillAfter a timed-out probe only gets
364 // SIGTERM, so a group member that ignores it outlives the call.
365 it.effect("escalates timed-out probes to SIGKILL", () => {
packages/tailscale/src/tailscale.ts
+7 -2
@@ -405,8 +405,13 @@ const runTailscaleCommand = Effect.fn("tailscale.runTailscaleCommand")(function*
405 Effect.fail(new TailscaleCommandSpawnError({ ...commandContext, cause })),
406 ),
407 );
408 - const [stderr, exitCode] = yield* Effect.all(
409 - [collectStderr(child.stderr), child.exitCode.pipe(Effect.map(Number))],
408 + // An unread stdout pipe fills on a long success summary and blocks the child before it exits.
409 + const [, stderr, exitCode] = yield* Effect.all(
410 + [
411 + Stream.runDrain(child.stdout),
412 + collectStderr(child.stderr),
413 + child.exitCode.pipe(Effect.map(Number)),
414 + ],
415 { concurrency: "unbounded" },
416 ).pipe(
417 Effect.mapError((cause) => new TailscaleCommandOutputError({ ...commandContext, cause })),