You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Quick repeated calls to await @Fetch*.load(...).task inside .task modifier can result in stale query results #557
Quick repeating calls to load can occur naturally in situations like handling a deep link on application start: the application first loads the initial/default query, followed by a quick reload to process the deep link.
Investigation reveals that awaiting the FetchSubscription.task is what triggers this bug. There's a race between the cancellation of the task (which will occur when the await is situated inside a view's .task modifier) and the handling of the new load. If the cancel wins, it prevents the new load from succeeding, resulting in stale data.
See attached demo app for a controllable repro - SubscriptionTaskReloadRaceApp_1.12.0.zip. The app cycles between query states A -> B -> C -> D, which each have their respective expected results ([A,A..], [B, B, ..], etc.). The app will halt whenever displayed results do not match expected results based on the most recent load call. Lowering the "Replacement load delay" to below 100ms reliably triggers the mismatch/stale results state. repro video
Checklist
I wrote this in my own words, and aimed to be as succinct as possible, even if I used AI to help research its content.
I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
I have determined whether this bug is also reproducible in a vanilla GRDB project.
If possible, I've reproduced the issue using the main branch of this package.
Activity
jsutula commentedon Sep 30, 2026
Stephen has a PR out to fix this: #536
mbrandonw commentedon Oct 2, 2026
Hi @jsutula, yep we will get back to that PR soon! Thanks for reminding us...
mbrandonw commentedon Nov 4, 2026
This has been fixed in #536 and was merged and will be released soon!