fix: resolve data race on the process exit code#139
Conversation
Start reaped the process in a goroutine (go cmd.Wait(), which writes cmd.ProcessState) while Status/Stop read cmdState.Cmd.ProcessState concurrently — a data race flagged by go test -race. Use the shared extcmd.CmdState.Wait()/ExitCode() API: the Wait goroutine is the sole reader of ProcessState and the handlers read the exit code race-free. The liveness Signal(0) check still reads cmd.Process, which Wait does not write, so it is unaffected.
|
Claude finished @joshiste's task in 1m 39s —— View job Claude's Review
Summary: This is a clean, minimal fix for the data race described in the PR body. I traced the change through
This correctly eliminates the race between the reaping goroutine and the status/stop handlers, consistent with the new No bugs, security issues, or new concurrency problems found in the diff. Two notes, neither blocking:
I was unable to run |
|



Problem
Startreaped the process in a goroutine (go cmd.Wait(), which writescmd.ProcessState) whileStatus/StopreadcmdState.Cmd.ProcessState.ExitCode()concurrently — a data race thatgo test -raceflags and that can yield torn reads of the process result.Fix
Use the shared
extcmd.CmdState.Wait()/ExitCode()API added in extension-kit#149:CmdStateowns the process result,Wait()is the sole reader ofcmd.ProcessState, andExitCode()returns it race-free (-1while running).Startnow doesgo cmdState.Wait(); the handlers readcmdState.ExitCode().This is the same fix applied across the four extensions that share this
extcmdpattern (extension-gatling, extension-jmeter, extension-k6, extension-postman).Dependency
extension-kitis pinned to the unreleased commit (v1.10.6-0.20260630192502-059086860afd) until #149 is merged and tagged; the pin should be bumped to the tagged release before merge.Verification
go build ./...,go vet ./...,go test -race ./...pass.