Skip to content

Fix extension startup initialization race #9986

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:

go test -race ./cmd/middleware -run "^TestStartAndWaitExtension_PropagatesTraceContext$" -count=100

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/ext-frameworkExtension SDK, gRPC, runnerbugSomething isn't workingflaky testtest flakiness

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions