From: Carlos Amedee Date: Fri, 3 Jan 2025 21:53:32 +0000 (-0500) Subject: os: force a goroutine to be scheduled on WASM X-Git-Tag: go1.24rc3~2^2~24 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5a46b17b5f;p=gostls13.git os: force a goroutine to be scheduled on WASM The TestRootConcurrentClose test can fail when GOARCH=WASM because of goroutine starvation. The spawned goroutine will sometimes run in a loop and never have the main goroutine be scheduled. This causes the test to fail due to a timeout. This change forces the goroutine to be scheduled with each iteration of the loop when GOARCH=WASM. For #71134 Fixes #71117 Change-Id: I4fb68907c9ac3b33bd0572d5e5db2974a3379191 Reviewed-on: https://go-review.googlesource.com/c/go/+/640195 Reviewed-by: Michael Knyszek Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI Auto-Submit: Carlos Amedee --- diff --git a/src/os/root_test.go b/src/os/root_test.go index b461ee2208..cbb985b2ce 100644 --- a/src/os/root_test.go +++ b/src/os/root_test.go @@ -1077,6 +1077,10 @@ func TestRootConcurrentClose(t *testing.T) { first = false } f.Close() + if runtime.GOARCH == "wasm" { + // TODO(go.dev/issue/71134) can lead to goroutine starvation. + runtime.Gosched() + } } }() if err := <-ch; err != nil {