fix(anki-26.09): defer reloading the page until 'Save & Optimize' has been handled - #22165
Merged
Merged
Conversation
In 26.09, save & optimize performed a refresh, which was a legitimate bug if there was a delayed response. These extracted functions allow the next commit to focus on the race condition via properly detecting a reload. Part of 21926 Assisted-by: GPT-6
Part of 21926 Assisted-by: GPT-6
Reading a cloned response was not a good signal. Instead, observe `blob()`. Assisted-by: GPT-6
We want to guard against navigation while the operation is in progress. fetch/body-read errors are rethrown (frontend displays them). Assisted-by: GPT-6
The 26.09 frontend reloads immediately after starting Save & Optimize. This needs to be deferred until we have consumed the response * if we get a failure; we don't want to navigate away, as this loses state * if we navigate during the frontend reading the body, it is treated as an error Requesting the reload is still required for 26.05. Part of 21926 Assisted-by: GPT-6
david-allison
force-pushed
the
anki-26-09-2-part-8
branch
from
September 28, 2026 23:06
20507ef to
0abf23b
Compare
mikehardy
approved these changes
Sep 30, 2026
mikehardy
left a comment
Member
There was a problem hiding this comment.
LGTM — after adversarial review + local CI-parity (lint/unit/emulator on API36_GAPI_PS16K) on a rebase onto current main.
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.
Note
Assisted-by: GPT-6
Purpose / Description
In 26.09, Save & Optimize starts a save, then reloads. This can interrupt the response to AnkiDroid and broke one of our instrumentation tests.
This appears to be a legitimate failure due to a missing
await: https://github.com/ankitects/anki/blob/41d7464c9b673e2aa15f76daa76d77ee110d7533/ts/routes/deck-options/FsrsOptions.svelte#L352-L353Fixes
Approach
We hook into the save request, deferring a page reload until the frontend has handled the successful response.
We work around this by hooking into
blob()and reporting this to AnkiDroid. After the read occurred, it's safe to reload (even if this discards the UI handling of the response - we were reloading anyway).How Has This Been Tested?
Heavily unit tested, the existing instrumented test now passes.
Checklist