From e24b3320516cc040ed7c033f09759dbba41d7a8e Mon Sep 17 00:00:00 2001 From: forever Date: Wed, 7 Oct 2026 15:19:50 -0700 Subject: [PATCH] plugin: a failed write to the plugin host ends the host before its caller hears of it, so a call freed by the failure finds the host already gone (TestHostWriterFailureWakesWaiters, red on macOS CI) (#1214) --- internal/plugin/host.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/plugin/host.go b/internal/plugin/host.go index 49bd7f8f..79acef1b 100644 --- a/internal/plugin/host.go +++ b/internal/plugin/host.go @@ -988,11 +988,15 @@ func (h *host) writerLoop() { return } _, err := h.in.Write(req.b) + if err != nil { + // End the host before the writer's caller hears of it, so a + // caller freed by the failure finds the host already dead. + h.fail(fmt.Errorf("writing to the plugin host: %w", err)) + } if req.done != nil { req.done <- err } if err != nil { - h.fail(fmt.Errorf("writing to the plugin host: %w", err)) return } }