|
1 | 1 | import { assert, describe, it } from "@effect/vitest"; |
| 2 | +import * as Deferred from "effect/Deferred"; |
2 | 3 | import * as Duration from "effect/Duration"; |
3 | 4 | import * as Effect from "effect/Effect"; |
| 5 | +import * as Exit from "effect/Exit"; |
| 6 | +import * as Fiber from "effect/Fiber"; |
4 | 7 | import * as Layer from "effect/Layer"; |
5 | 8 | import * as Sink from "effect/Sink"; |
6 | 9 | import * as Stream from "effect/Stream"; |
| 10 | +import * as TestClock from "effect/testing/TestClock"; |
7 | 11 | import { ChildProcessSpawner } from "effect/process"; |
8 | 12 | import * as HostProcess from "@t3tools/shared/HostProcess"; |
9 | 13 |
|
@@ -317,6 +321,45 @@ describe("tailscale", () => { |
317 | 321 | }); |
318 | 322 | }); |
319 | 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 | + |
320 | 363 | // regression: #21609 - without forceKillAfter a timed-out probe only gets |
321 | 364 | // SIGTERM, so a group member that ignores it outlives the call. |
322 | 365 | it.effect("escalates timed-out probes to SIGKILL", () => { |
|
0 commit comments