Skip to content

Fix repeated Flush calls returning before uploads finish - #5

Merged
PetrHeinz merged 1 commit into
BetterStackHQ:mainfrom
agocharbhatia:fix-flush-outstanding-uploads
Nov 3, 2026
Merged

PetrHeinz merged 1 commit into
BetterStackHQ:mainfrom
agocharbhatia:fix-flush-outstanding-uploads

Conversation

@agocharbhatia

Copy link
Copy Markdown
Contributor

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.

@PetrHeinz

Copy link
Copy Markdown
Member

Hi @agocharbhatia, thanks for the contribution!

I'm merging this and releasing as a patch version 🚀

@PetrHeinz
PetrHeinz merged commit 5a8024a into BetterStackHQ:main Nov 3, 2026
16 checks passed
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.

2 participants