From 670af70112ab148ea02714267d709902d40974cc Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 04:17:15 -0600 Subject: [PATCH] fix(mcpx): bound sdnotify writes so abstract sockets cannot hang the suite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Run 41819578987: TestAbstractSocketName hung the full 1800s test timeout inside sdnotify.Send in a container where an abstract unixgram write blocks instead of erroring, cascading the mcpx failure into the opencode and openchamber derivation builds. Send now writes under a 5s deadline (sd_notify is fire-and-forget; a daemon must never wedge on an unresponsive socket), and the test runs Ready under a 15s watchdog that skips with the environment reason named instead of hanging. Tests: go test ./internal/sdnotify/ — 4/4. --- pkgs/mcpx/internal/sdnotify/sdnotify.go | 9 +++++++++ pkgs/mcpx/internal/sdnotify/sdnotify_test.go | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/pkgs/mcpx/internal/sdnotify/sdnotify.go b/pkgs/mcpx/internal/sdnotify/sdnotify.go index fdd3271b74..eaa6f378fb 100644 --- a/pkgs/mcpx/internal/sdnotify/sdnotify.go +++ b/pkgs/mcpx/internal/sdnotify/sdnotify.go @@ -7,8 +7,16 @@ import ( "fmt" "net" "os" + "time" ) +// writeTimeout bounds one notify write. sd_notify is fire-and-forget: +// a daemon must never wedge on an unresponsive socket (in some +// container environments an abstract unixgram write blocks instead of +// erroring — run 41819578987 hung 1800s there), so the write carries +// a deadline and the failure surfaces as an ordinary error. +const writeTimeout = 5 * time.Second + // Send writes one state assignment, such as "READY=1", to $NOTIFY_SOCKET. // Outside systemd the variable is unset and Send does nothing. func Send(state string) error { @@ -23,6 +31,7 @@ func Send(state string) error { return fmt.Errorf("notify %s: %w", path, err) } defer func() { _ = conn.Close() }() + _ = conn.SetWriteDeadline(time.Now().Add(writeTimeout)) if _, err := conn.Write([]byte(state)); err != nil { return fmt.Errorf("notify %s: %w", path, err) } diff --git a/pkgs/mcpx/internal/sdnotify/sdnotify_test.go b/pkgs/mcpx/internal/sdnotify/sdnotify_test.go index db88f0aac0..2b74441802 100644 --- a/pkgs/mcpx/internal/sdnotify/sdnotify_test.go +++ b/pkgs/mcpx/internal/sdnotify/sdnotify_test.go @@ -65,8 +65,21 @@ func TestAbstractSocketName(t *testing.T) { conn := listen(t, name) t.Setenv("NOTIFY_SOCKET", name) - if err := Ready(); err != nil { - t.Fatal(err) + // In some container environments an abstract unixgram write blocks + // indefinitely instead of completing or erroring (run 41819578987 + // hung the full 1800s test timeout, cascading an unrelated build). + // Send is deadline-bounded in production; if even that does not + // return here, the environment cannot do abstract sockets — skip + // with the reason rather than hang the suite. + done := make(chan error, 1) + go func() { done <- Ready() }() + select { + case err := <-done: + if err != nil { + t.Fatal(err) + } + case <-time.After(15 * time.Second): + t.Skipf("abstract unixgram notify to %s did not complete in 15s; this environment blocks abstract-socket writes", name) } if got := next(t, conn); got != "READY=1" { t.Fatalf("Ready sent %q", got)