reader: fix spinner stuck forever on slow first page-image load#711
Merged
ajslater merged 1 commit intov1.11-performancefrom May 4, 2026
Merged
Conversation
The ``v-else-if`` / ``v-else`` chain on the page wrapper made ``LoadingPage`` and the image component mutually exclusive. When the 333ms ``mounted()`` timer flipped ``showProgress=true``, Vue swapped to ``LoadingPage`` — destroying the ``<img>`` element along with its ``@load`` listener. Any response arriving after that landed on a torn-down element, ``loaded`` never flipped, and the spinner stuck forever. Only reproduced in production: behind an nginx reverse proxy with cold caches, the first page-image request crossed 333ms; on ``make dev-prod-server`` against ``localhost`` the image came back well under the threshold so the swap never fired. Render ``<component>`` and ``LoadingPage`` as siblings under ``v-else`` with ``v-show`` toggling component visibility instead of ``v-if``. The component stays mounted across the spinner transition, the ``@load`` handler is still wired when the response lands, and the visible behaviour matches the previous template at each state (image during 0–333ms grace, spinner while loading beyond that, image once loaded, ErrorPage on error). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
The reader page wrapper used a
v-else-if/v-elsechain that madeLoadingPageand the image component mutually exclusive. When the 333msmounted()timer flippedshowProgress=true, Vue swapped toLoadingPage— destroying the<img>element along with its@loadlistener. Any response arriving after that landed on a torn-down element,loadednever flipped, and the spinner stuck forever.The fix renders
<component>andLoadingPageas siblings underv-elsewithv-showtoggling component visibility instead ofv-if. The component stays mounted across the spinner transition, the@loadhandler is still wired when the response lands, and the visible behaviour matches the previous template at each state.Why it only repro'd in production
The bug needs the page-image request to cross 333ms.
make dev-server/make dev-prod-server→ API onlocalhost, request returns well under 333ms → swap never fires → no repro./api/v3/c/<pk>/<page>/page.jpgcrosses 333ms → swap fires →<img>unmounts mid-flight.The reproducer's other quirks fall out cleanly:
Confirmed via DOM inspection on a stuck instance
The current page's
<img>is gone; only the spinner remains.Behavior matrix (unchanged externally)
Test plan
bun run build(frontend) cleanbun run test:ci(vitest) passeseslint+prettierclean for the changed filemake dev-prod-server), confirm no visible spinner flash on cached-image second open, normal spinner on first slow open.🤖 Generated with Claude Code