From 44e1fec3a66e8a621c10b56cc6cb67371dc9f7ec Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 28 Oct 2026 18:37:52 +0800 Subject: [PATCH] gateway: the try a lost ping cut doesn't fail the upload test (#4033) TestUploadStillUnderwayIsNotCutByHealthPing was red 3 of 3 on WSL (magpie-desktop) at 7fe98c2af with "the vendor reading the body: client disconnected", while the gateway got the vendor's right reply in 4.7s. Cause: the #3909 fix lets the first try be cut by the lost ping, then sends the body again. Both tries reach the vendor (counted on WSL and mote: tries=2 each run). The cut try's handler stays blocked reading, since the paced path never closes its vendor side, until the test's cleanup closes the path. On Linux that read then fails, and the handler's t.Errorf turned the test red. On macOS the abandoned try ends without an error. The test asserted something the fix doesn't promise. The reply's byte count still proves one try read the whole body. What was run at this change on origin/main 7fe98c2af: - gofmt -l internal/gateway: nothing; go vet ./internal/gateway/ (mote): ok. - WSL: TestUploadStillUnderwayIsNotCutByHealthPing, TestSlowUplinkSkipsTheLostTry, TestLargeBodyOnSilentConnectionIsSentAgain -count=5: ok (70.6s). Before the change the first was red 3 of 3. - mote: the same three, -race -count=3: ok. Windows (xiaomi-gpu): -count=3: ok. - Broken by hand (the lostPing retry turned off), WSL: the test FAILs in 0.56s with "http2: client connection lost; want the vendor's reply". Rebased onto e1721d640 (a GUI routing change only): the three tests again on WSL -count=3 and mote -count=2: ok. --- internal/gateway/upstream_h2_upload_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/gateway/upstream_h2_upload_test.go b/internal/gateway/upstream_h2_upload_test.go index d779cc881..eb2c0c21a 100644 --- a/internal/gateway/upstream_h2_upload_test.go +++ b/internal/gateway/upstream_h2_upload_test.go @@ -112,7 +112,9 @@ func TestUploadStillUnderwayIsNotCutByHealthPing(t *testing.T) { vendor := h2Vendor(t, func(w http.ResponseWriter, r *http.Request) { n, err := io.Copy(io.Discard, r.Body) if err != nil { - t.Errorf("the vendor reading the body: %v", err) + // the try the lost ping cut, given up for the one sent again; + // it ends when the path closes, after the test (#4033) + return } fmt.Fprintf(w, "%s %d", r.Proto, n) })