Skip to content

Commit 4b4962c

Browse files
committed
store [nfc]: Re-query account after _registerQueueWithRetry async gap
I believe this is NFC because: - the only fields we read are zulipVersion, zulipMergeBase, and zulipFeatureLevel - we read those fields only to update them if needed - nothing else could have written to those fields during the async gap; this register-queue codepath is the only codepath that writes to them, and we don't allow concurrent register-queues for an account But we've been using an Account object from across an async gap, and that looks like a code smell that calls for a fix.
1 parent fc94d99 commit 4b4962c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/model/store.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,8 @@ class UpdateMachine {
976976
final t = (stopwatch..stop()).elapsed;
977977
assert(debugLog("initial fetch time: ${t.inMilliseconds}ms"));
978978

979+
// `!` is OK because _registerQueueWithRetry would have thrown if no account
980+
account = globalStore.getAccount(accountId)!;
979981
if (initialSnapshot.zulipVersion != account.zulipVersion
980982
|| initialSnapshot.zulipMergeBase != account.zulipMergeBase
981983
|| initialSnapshot.zulipFeatureLevel != account.zulipFeatureLevel) {

0 commit comments

Comments
 (0)