coder / envbuilder

Build development environments from a Dockerfile on Docker, Kubernetes, and OpenShift. Enable developers to modify their development environment quickly.
Apache License 2.0
130 stars 25 forks source link

fix: prevent git progress writer race reading stageNumber #309

Closed mafredri closed 1 month ago

mafredri commented 1 month ago

Since the progress writer runs in a goroutine, it can call the write function after the git operation has exited and while the next stage is starting, resulting in a race. This fixes the race by using a second variable and closing the writer early.

An alternative fix is to rewrite the progress writer to be synchronous.