From 7c96458d8c7657f2256589bb57b7c69dd41c113a Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 28 Mar 2026 09:13:21 +0800 Subject: [PATCH] fix(tai/tunnel): handle concurrent "open" frames in TestRegister_Ping In CI environments where a real tai gRPC endpoint is reachable on port 19100, the asynchronous connectTunnelNode goroutine can dial successfully and send an "open" TunnelControl frame on the Register stream before the test's "pong" arrives. Loop on Recv() and skip non-pong frames so the test passes regardless of whether connectTunnelNode fires in the background. Made-with: Cursor --- tai/tunnel/grpc_handler_test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tai/tunnel/grpc_handler_test.go b/tai/tunnel/grpc_handler_test.go index b5d97558..54cbeead 100644 --- a/tai/tunnel/grpc_handler_test.go +++ b/tai/tunnel/grpc_handler_test.go @@ -185,12 +185,18 @@ func TestRegister_Ping(t *testing.T) { t.Fatal(err) } - pong, err := stream.Recv() - if err != nil { - t.Fatal(err) - } - if pong.Type != "pong" { - t.Errorf("expected pong, got %q", pong.Type) + // Loop until we receive "pong"; skip "open" frames that may arrive from + // the asynchronous connectTunnelNode goroutine if a real gRPC endpoint + // happens to be reachable in the test environment. + for { + pong, err := stream.Recv() + if err != nil { + t.Fatal(err) + } + if pong.Type == "pong" { + break + } + // skip unexpected frames (e.g. "open" from connectTunnelNode) } stream.CloseSend()