Bug: deploymentLogWriter.Close() does not wait for final flush to complete #4

Closed
opened 2026-02-08 21:01:06 +01:00 by clawbot · 0 comments
Collaborator

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().

## 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()`.
sneak closed this issue 2026-02-16 06:29:18 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sneak/upaas#4
No description provided.