Skip to content

Fix repeated Flush calls returning before uploads finish - #5

Open
agocharbhatia wants to merge 1 commit into
BetterStackHQ:mainfrom
agocharbhatia:fix-flush-outstanding-uploads
Open

agocharbhatia wants to merge 1 commit into
BetterStackHQ:mainfrom
agocharbhatia:fix-flush-outstanding-uploads

Conversation

@agocharbhatia

Copy link
Copy Markdown

Problem

A repeated or overlapping Flush can return success while an earlier upload is still unacknowledged. This also happens when the first caller cancels its wait. The sender transfers its pending uploads to the first waiter and clears the list, so subsequent calls lose sight of that work.

Change

Keep tracking unfinished uploads and copy the outstanding set for each flush waiter. This preserves the boundary between earlier and later work without changing upload concurrency, retries, queueing or Close.

Verification

An offline HTTP fixture holds the first upload open. The same tests fail on current main for overlapping and cancelled-first-call cases, then pass with this patch. A separate test ensures an earlier flush does not wait for later uploads.

go test -race -count=1 -v ./... passes locally, including the existing goroutine leak checks. Vet, build and formatting also pass on Go 1.25.4/macOS arm64. No live Better Stack endpoint or hosted CI result is claimed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant