From c6ec6e95865dd93cec0fcea38c017560734141b0 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Mon, 26 Oct 2026 22:24:09 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(cmd/hive):=20tear=20down=20s?= =?UTF-8?q?idecar=20event=20stream=20and=20hosted=20runtime=20in=20supervi?= =?UTF-8?q?sion=20boot=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test never unsubscribed the sidecar client's event observer, so streamEvents kept reconnecting to the closed httptest server. Clear the observer in t.Cleanup, which runs before the server closes. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/cmd/hive/agent_runtime_supervise_test.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cmd/hive/agent_runtime_supervise_test.go b/src/cmd/hive/agent_runtime_supervise_test.go index 1426a77451..b0805cbdf8 100644 --- a/src/cmd/hive/agent_runtime_supervise_test.go +++ b/src/cmd/hive/agent_runtime_supervise_test.go @@ -199,7 +199,19 @@ func TestBootAgentsWith_SidecarStartsSupervision(t *testing.T) { t.Setenv(cruxconfig.ServeTokenEnvVar, "tok") f := newBootAgentsFake() f.deps.newRuntime = func(cfg cruxconfig.RuntimeConfig, opts ...cruxruntime.Option) (hostedRuntime, error) { - return newHostedRuntime(cfg, opts...) + hr, err := newHostedRuntime(cfg, opts...) + if err == nil { + // Cleanups run LIFO, so this unsubscribes (and joins the stream + // goroutine) before liveServe's httptest server is closed. + t.Cleanup(func() { + if sh, ok := hr.(*sidecarHost); ok { + if src, ok := sh.Runtime.(eventObservable); ok { + src.SetEventObserver(nil) + } + } + }) + } + return hr, err } f.deps.startHiveCallback = func(context.Context, callback.Capabilities, *slog.Logger) error { return nil } b := newBootAgentsBoot(t, f, bootAgentsConfig())