Fix useTable isReady reverting to false after first row event#4580
Open
clockwork-labs-bot wants to merge 1 commit intomasterfrom
Open
Fix useTable isReady reverting to false after first row event#4580clockwork-labs-bot wants to merge 1 commit intomasterfrom
clockwork-labs-bot wants to merge 1 commit intomasterfrom
Conversation
The subscribe callback passed to useSyncExternalStore captured computeSnapshot in its closure but did not list it as a dependency. When subscribeApplied flipped to true, computeSnapshot was recreated with the new value, but subscribe still held the stale closure that permanently captured subscribeApplied = false. Adding computeSnapshot to subscribe's dependency array ensures the event handlers always call the current computeSnapshot, so isReady stays true after onApplied fires.
bfops
reviewed
Mar 6, 2026
| connectionState, | ||
| accessorName, | ||
| querySql, | ||
| computeSnapshot, |
Collaborator
There was a problem hiding this comment.
I notice we explicitly disable the lint to check that the dependency array is exhaustive, so I'm a little wary of making innocuous-looking changes. I'm not sure who put that there (or if it was AI).
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.
Fixes #4559.
Bug
The
subscribecallback passed touseSyncExternalStorecapturescomputeSnapshotin its closure but did not list it as a dependency. WhensubscribeAppliedflips totrue:computeSnapshotis recreated withsubscribeApplied = truesubscribestill holds the stale closure that capturedsubscribeApplied = falsecomputeSnapshotwrites[rows, false]intolastSnapshotRefisReadydrops tofalsepermanentlyFix
Add
computeSnapshotto thesubscribedependency array so event handlers always use the current snapshot function.Note: PR #4499 previously fixed a related issue where the cached snapshot was stale after
subscribeAppliedchanged. This fix addresses the remaining case where thesubscribeclosure itself was stale.