Drop a grounding read that a newer one replaced - #40
Merged
Merged
Conversation
jserv
reviewed
Sep 14, 2026
jserv
reviewed
Sep 14, 2026
ColtenOuO
force-pushed
the
fix-grounding-stale-read
branch
from
September 14, 2026 17:25
62033bf to
0cd80d6
Compare
Collaborator
Author
|
The The fix is |
Contributor
Go ahead. |
A file read that was still in flight committed its result whenever it landed. Picking a second JD before the first finished reading could leave the first one's snippets under the second file's name, and a resume read when Clear was pressed brought the cleared snippets back. Each document kind now counts its reads and Clear bumps both, so a read that is no longer the latest one is dropped without touching the lists or the status line.
ColtenOuO
force-pushed
the
fix-grounding-stale-read
branch
from
September 14, 2026 20:11
0cd80d6 to
0f79ad5
Compare
Collaborator
Author
|
rebase to the main, CI looks green! |
jserv
reviewed
Sep 14, 2026
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.
Follow-up to #39.
Sumarry
loadGroundingFilewrote its result whenever the file read finished, even if a newer action had happened in the meantime:Fix and Change
Each document kind keeps a read counter (
groundingReads.jd/.resume). A read takes the next number before itsawaitand gives up afterwards if the number is no longer current, so it touches neithergrounding, the status line, nor the lists. Clear bumps both counters. The counters are per kind so a JD read never cancels a resume read.New test
Two
lobbyTests intests/browser/lobby.test.js. They hold the read of a file namedslow.txtopen by wrappingBlob.prototype.arrayBuffer, and release it on purpose.Summary by cubic
Fixes a race condition where a grounding file read that finished later could replace the result of a newer read, leaving the file list and snippets out of sync. Reads now use per-kind counters, and a read that is no longer the latest is dropped without touching the lists or status line.
Bug Fixes
Written for commit 0f79ad5. Summary will update on new commits.