Problem
TestStartAndWaitExtension_PropagatesTraceContext can time out instead of returning the extension process error. The extension startup goroutine and readiness waiter can concurrently call Extension.ensureInit(), causing the extension state—including readySignal—to be initialized more than once. The process error may then be delivered to a different channel from the one observed by WaitUntilReady.
This surfaced twice in the Windows build for #9934 and reproduces with the Go race detector. The defect already exists on main; it is not caused by the gRPC dependency update.
Proposed fix
Initialize the extension standard streams/readiness state before starting the extension goroutine. This ensures both process failure signaling and readiness waiting use the same initialized state.
Validation
Run the targeted test repeatedly with the race detector:
go test -race ./cmd/middleware -run "^TestStartAndWaitExtension_PropagatesTraceContext$" -count=100
Problem
TestStartAndWaitExtension_PropagatesTraceContextcan time out instead of returning the extension process error. The extension startup goroutine and readiness waiter can concurrently callExtension.ensureInit(), causing the extension state—includingreadySignal—to be initialized more than once. The process error may then be delivered to a different channel from the one observed byWaitUntilReady.This surfaced twice in the Windows build for #9934 and reproduces with the Go race detector. The defect already exists on
main; it is not caused by the gRPC dependency update.Proposed fix
Initialize the extension standard streams/readiness state before starting the extension goroutine. This ensures both process failure signaling and readiness waiting use the same initialized state.
Validation
Run the targeted test repeatedly with the race detector: