Skip to content

fix(frontseat-store): GH-266 bound the slice, not the subscribe cursor - #267

Open
joaodinissf wants to merge 1 commit into
mainfrom
fix/266-journal-subscribe-beyond-end
Open

fix(frontseat-store): GH-266 bound the slice, not the subscribe cursor#267
joaodinissf wants to merge 1 commit into
mainfrom
fix/266-journal-subscribe-beyond-end

Conversation

@joaodinissf

Copy link
Copy Markdown
Collaborator

Subscribe clamped its cursor down to len(events) as it stood when the
delivery goroutine happened to start. The clamp was there to stop a cursor past
the end panicking on the first wake, but bounding the cursor rather than the
slice left a subscriber that over-asked tailing from wherever the journal was
at that instant — delivering sequences below the one it asked for.

The cursor now stays at fromSeq-1 as a permanent floor and the slice is
bounded instead, so an over-asking subscriber yields nothing, matching the
replay path. Carrying it as an int64 also removes the wrap-to-negative index
a wire value near math.MaxInt64 could produce.

TestJournalSubscribeBeyondEnd/finished caught this about once in 3000 runs,
which was enough to redden unrelated PRs. 4000 iterations and the race detector
are clean now.

Fixes #266

This pull request was published with assistance from Claude.

@joaodinissf
joaodinissf requested a review from jbadeau July 29, 2026 22:12
Subscribe clamped its cursor down to len(events) as it stood when the
delivery goroutine happened to start. The clamp was there to stop a
cursor past the end panicking on the first wake, but bounding the cursor
rather than the slice left a subscriber that over-asked tailing from
wherever the journal was at that instant, delivering sequences below the
one it asked for.

Keep the cursor at fromSeq-1 as a permanent floor and bound the slice
instead, so an over-asking subscriber yields nothing — matching the
replay path. Carrying it as an int64 also removes the wrap-to-negative
index a wire value near math.MaxInt64 could produce.

TestJournalSubscribeBeyondEnd/finished caught this about once in 3000
runs; 4000 iterations and the race detector are clean now.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@joaodinissf
joaodinissf force-pushed the fix/266-journal-subscribe-beyond-end branch from f06da03 to 77cec36 Compare August 1, 2026 20:25
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.

store: journal Subscribe delivers events below the requested sequence

1 participant