From 99111f39fbe9246a5bb7003111c4e7d7a3fca83f Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Fri, 21 Aug 2026 20:27:49 -0300 Subject: [PATCH] fix(services): isolate probeBeforeSpawn adoption tests on distinct ports to stop order-dependent flake (#10523) (#11061) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⭐5 — Fix do dono com TDD. Estado committed+pushed limpo (hold-vivo cedido por instrução direta do operador). --- .../fixes/10523-servicesupervisor-port-flake.md | 1 + tests/unit/services/ServiceSupervisor.test.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 changelog.d/fixes/10523-servicesupervisor-port-flake.md diff --git a/changelog.d/fixes/10523-servicesupervisor-port-flake.md b/changelog.d/fixes/10523-servicesupervisor-port-flake.md new file mode 100644 index 0000000000..1a98ea7fa2 --- /dev/null +++ b/changelog.d/fixes/10523-servicesupervisor-port-flake.md @@ -0,0 +1 @@ +- fix(services): isolate probeBeforeSpawn adoption tests on distinct ports to stop the order-dependent flake (#10523) \ No newline at end of file diff --git a/tests/unit/services/ServiceSupervisor.test.ts b/tests/unit/services/ServiceSupervisor.test.ts index fe0d6d82bc..011395733a 100644 --- a/tests/unit/services/ServiceSupervisor.test.ts +++ b/tests/unit/services/ServiceSupervisor.test.ts @@ -244,8 +244,16 @@ test("#6205: probeBeforeSpawn adopts a healthy existing instance (no spawn)", as // healthy, running service as untrustworthy/stale. This asserts the resolved // pid on adoption matches the real process actually holding the port. test("adopted service resolves and records the real pid of the process holding the port", async () => { - const healthServer = startHealthServer(29996); - const cfg = { ...tickConfig("test-adopt", 29996), probeBeforeSpawn: true }; + // Use a distinct port from the other probeBeforeSpawn adoption test above. + // Both originally shared 29996, and Node's undici fetch() keep-alive pool + // (used by isHealthy() in portProbe.ts) caches a socket keyed only by + // host:port, so the second test's fetch could be replayed over a stale + // connection from the first test's health server instance, failing the + // probe and flipping the adoption into a spurious "error" state. A separate + // port keeps each probe isolated from the other test's pooled connection + // (#10523). + const healthServer = startHealthServer(29995); + const cfg = { ...tickConfig("test-adopt", 29995), probeBeforeSpawn: true }; const sup = new ServiceSupervisor(cfg); try {