From a64483885cf25a1c1b46f7d732680d31d4a63807 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 11 May 2026 10:25:37 -0700 Subject: [PATCH] fix(pb): skip Unix-socket gRPC registration on Windows (#9430) (#9434) The same-host gRPC fast path registered /tmp/...sock paths and dialed them with net.Listen("unix", ...) / net.Dial("unix", ...). Those paths are POSIX-only, so on Windows the listener failed at startup and every local gRPC call routed through the registered port lost its transport. Gate RegisterLocalGrpcSocket to return early on Windows. ServeGrpcOnLocalSocket and resolveLocalGrpcSocket already short-circuit when no socket is registered, so all same-host RPCs fall back to TCP without touching any callsite. --- weed/pb/grpc_client_server.go | 9 +++++++++ weed/pb/grpc_client_server_test.go | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/weed/pb/grpc_client_server.go b/weed/pb/grpc_client_server.go index e26d6278b..b3aff37a9 100644 --- a/weed/pb/grpc_client_server.go +++ b/weed/pb/grpc_client_server.go @@ -8,6 +8,7 @@ import ( "net" "net/http" "os" + "runtime" "strconv" "strings" "sync" @@ -81,7 +82,15 @@ func init() { // GrpcDial to host:grpcPort (or to a loopback alias of host on the same // port) is routed through the Unix socket. Dials to any other host on the // same port still go over TCP. +// +// No-op on Windows: the /tmp/...sock paths callers pass are POSIX-only and +// the listen/dial would fail at runtime, taking gRPC down with it (#9430). +// Skipping registration leaves the maps empty, so ServeGrpcOnLocalSocket +// and resolveLocalGrpcSocket short-circuit and same-host RPCs go over TCP. func RegisterLocalGrpcSocket(host string, grpcPort int, socketPath string) { + if runtime.GOOS == "windows" { + return + } localGrpcSocketsLock.Lock() defer localGrpcSocketsLock.Unlock() localGrpcSockets[grpcPort] = socketPath diff --git a/weed/pb/grpc_client_server_test.go b/weed/pb/grpc_client_server_test.go index 210578d68..bdc3cc48b 100644 --- a/weed/pb/grpc_client_server_test.go +++ b/weed/pb/grpc_client_server_test.go @@ -2,6 +2,7 @@ package pb import ( "fmt" + "runtime" "testing" "google.golang.org/grpc/codes" @@ -74,6 +75,9 @@ func TestIsClientSideMarshalError_RequiresGrpcStatus(t *testing.T) { // continue out over TCP — they must NOT be hijacked into host A's local // socket on the basis of port match alone. func TestResolveLocalGrpcSocket_RemotePortCollision(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Unix-socket routing is disabled on Windows (#9430)") + } // Snapshot and restore global state so the test does not leak into others. localGrpcSocketsLock.Lock() prevSockets := localGrpcSockets