fix(web): repair response stream sequence gaps#878
Merged
SamSaffron merged 1 commit intoJun 28, 2026
Conversation
1fb0df6 to
78bb008
Compare
78bb008 to
e2a51c7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a hard sequence-continuity guard to the web response stream resume path.
If the browser believes it has applied sequence
4and the replay stream starts at7, the client now treats that as corruption, stops applying the tail, fetches the authoritative response snapshot, and resumes from the snapshot cursor instead of displaying1,2,3,4,[missing],7,8,9.Also fixes the server-side source of real holes: if a response event payload fails JSON encoding after reserving the next sequence number, the run now rolls the sequence counter back instead of burning a permanent gap.
Why
The UI was using
lastSequenceNumberas both:/v1/responses/:id/events?after=N, andN.That second invariant was not enforced. If replay/repair returned a non-contiguous event tail, or the local projection had already drifted, the browser could accept later events and permanently skip the missing middle.
The fix makes the invariant explicit:
lastSequenceNumber + 1must be the next event. If not, snapshot repair is mandatory.Tests
mise exec -- node internal/serveui/static/app_stream_test.jssuccessfully.go test ./...successfully.