In internal/service/deploy/deploy.go, deploymentLogWriter.Close() closes the done channel to signal the flush goroutine to stop, but does not wait for the goroutine to finish. The doFlush() in the goroutine writes buffered log data to the database, but the caller may proceed (and mark the deployment as finished or write logs to file) before the final flush completes.
Impact
Build log data may be lost. The last batch of log lines (up to 1 second worth) can be silently dropped.
Location
internal/service/deploy/deploy.go - deploymentLogWriter.Close() and runFlushLoop()
Fix
Add a sync.WaitGroup or second channel to wait for the flush goroutine to complete its final flush before returning from Close().
## Description
In `internal/service/deploy/deploy.go`, `deploymentLogWriter.Close()` closes the `done` channel to signal the flush goroutine to stop, but does not wait for the goroutine to finish. The `doFlush()` in the goroutine writes buffered log data to the database, but the caller may proceed (and mark the deployment as finished or write logs to file) before the final flush completes.
## Impact
Build log data may be lost. The last batch of log lines (up to 1 second worth) can be silently dropped.
## Location
`internal/service/deploy/deploy.go` - `deploymentLogWriter.Close()` and `runFlushLoop()`
## Fix
Add a `sync.WaitGroup` or second channel to wait for the flush goroutine to complete its final flush before returning from `Close()`.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Description
In
internal/service/deploy/deploy.go,deploymentLogWriter.Close()closes thedonechannel to signal the flush goroutine to stop, but does not wait for the goroutine to finish. ThedoFlush()in the goroutine writes buffered log data to the database, but the caller may proceed (and mark the deployment as finished or write logs to file) before the final flush completes.Impact
Build log data may be lost. The last batch of log lines (up to 1 second worth) can be silently dropped.
Location
internal/service/deploy/deploy.go-deploymentLogWriter.Close()andrunFlushLoop()Fix
Add a
sync.WaitGroupor second channel to wait for the flush goroutine to complete its final flush before returning fromClose().