Fix extension startup initialization race
- Dominant language
- Go
- Stars
- 569
- Forks
- 364
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 136
Description
## 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:
```sh
go test -race ./cmd/middleware -run "^TestStartAndWaitExtension_PropagatesTraceContext$" -count=100
```
Contributor guide
Assessment
This issue has not been assessed yet.