carlos / platform Public

host: the parked wake handler is released even when the test fails first

The re-review's one residual: release was closed only after the
in-flight assertion passed, so a t.Fatalf on that path left the
handler goroutine parked for the life of the test binary. t.Cleanup
closes it exactly once — the select reads a channel the success path
already closed, and closes it otherwise.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev a4c31540bdbb0851eb88b709d5418320a5eb9bb1 parent 907beb2
1 file changed, +12 −0
  • internal/host/schedule_wake_test.go +12 −0

CI passed — run details

diff --git a/internal/host/schedule_wake_test.go b/internal/host/schedule_wake_test.go
index bd55d1fbb..f5ea89ece 100644
--- a/internal/host/schedule_wake_test.go
+++ b/internal/host/schedule_wake_test.go
@@ -216,6 +216,18 @@ func TestScheduledTickWakesASleepingInstanceAndItHibernatesAgain(t *testing.T) {
// the handler run longer — it cannot turn the assertion red.
seen := make(chan *http.Request, 4)
release := make(chan struct{})
+ // If an assertion t.Fatalfs before the release below, the parked
+ // handler goroutine must not outlive the test holding this channel:
+ // close it on cleanup unless the success path already has. Reading a
+ // closed channel succeeds immediately, so the select stays correct
+ // after the normal close.
+ t.Cleanup(func() {
+ select {
+ case <-release:
+ default:
+ close(release)
+ }
+ })
reg, inst, svc, dd := wakeFixture(t, host, idle, func(w http.ResponseWriter, r *http.Request) {
seen <- r.Clone(context.Background())
<-release