Repository navigation
fix(admin): keep loads working when a component mounts again - #24
Merged
Merged
Conversation
useFetchClient (Strapi 5.62) aborts the requests of an unmounted component. The Online users widget and the Analytics page then skipped their next load because the aborted one still counted as running, and the Configuration page set the error of the aborted load after the next load had started. Under React.StrictMode (mount, unmount, mount) all three showed "could not be loaded". Each load now belongs to one mount; aborted or outdated loads set no state. Adds the admin StrictMode harness (tests/admin, npm run test:admin): every admin entry point mounted in React.StrictMode with the real Strapi admin providers in jsdom, fake network, counting of requests, timers, listeners, connections, observers and console output. CI runs it on React 18 and, for information only, on React 19. Docs read: react.dev/reference/react/StrictMode, react.dev/blog/2024/04/25/ react-19-upgrade-guide, @strapi/admin 5.62 useFetchClient.mjs, getFetchClient.mjs, DescriptionComponentRenderer.mjs and tests/utils.mjs (Providers), jsdom 31 README, Node 22 module customization hooks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 18, 2026
## [4.14.2](v4.14.1...v4.14.2) (2026-11-18) ### Bug Fixes * **admin:** keep loads working when a component mounts again ([#24](#24)) ([4a18a47](4a18a47)) ### Fixed * The Online users widget, the Analytics page and the Configuration page no longer show "could not be loaded" after the component is mounted a second time. `useFetchClient` aborts the requests of an unmounted component; the widget and the Analytics page then skipped their next load because the aborted one still counted as running, and the Configuration page set the error of the aborted load after the next load had started. React StrictMode mounts every component twice in development, and React 19 and a future StrictMode admin do the same. Each load now belongs to one mount: an aborted or outdated load sets no state. ### Tests * `npm run test:admin`: StrictMode tests for every admin entry point (no duplicate requests, no leaked timers, listeners, connections or observers after unmount, no console errors or warnings), also run against React 19 in an informational CI job.
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.
Plan item P2: React StrictMode and React 19 test harness for the admin code.
Bugs found and fixed (each with a regression test that fails before the fix)
useFetchClient(Strapi 5.62) aborts the requests of an unmounted component. In StrictMode (mount, unmount, mount):admin/src/components/OnlineUsersWidget.jsx: the in-flight guard still counted the aborted first load, so the remount skipped its load and the widget stayed on "Online users could not be loaded."admin/src/pages/Analytics.jsx: same guard; in addition the aborted request was treated as a failure. The page showed "Analytics could not be loaded."admin/src/pages/Settings/hooks/useSettingsForm.js: the aborted first load setloadErrorafter the second load had started, so the page stayed on "Settings could not be loaded." although the settings had loaded.Each load now belongs to one mount (request token / latest request id; the effect cleanup forgets the running load); aborted or outdated loads set no state. Verified by stashing the three fixes: the three regression tests fail, with the fixes all pass.
Harness
tests/admin/harness/*(shared with Magicmark) andtests/admin/strict-mode.test.jsx, run bynpm run test:admin. Every entry point is mounted inside<React.StrictMode>with the real Strapi admin providers (same tree as@strapi/admin/dist/admin/admin/tests/utils.mjsProviders), jsdom 31 and a fake network. Assertions: no mutation twice, no non-aborted duplicate GET, nothing left after unmount (intervals, timeouts, listeners, sockets, observers), no console error/warning.Entry points covered:
plugins/magic-sessionmanager/*: session dashboard (one live list + stats request, clock and auto-refresh intervals counted while mounted and gone after unmount, details dialog open/close, end-session confirmation open/cancel, debounced search) and admin panel sessions view (list + "View sessions" dialog).SessionInfoPanel, rendered through Strapi's ownDescriptionComponentRendererinside the adminForm(one live request, Block confirmation open/cancel; nothing for other models).React 19
npm install --no-save --legacy-peer-deps --ignore-scripts react@19 react-dom@19(19.3.1): 11/11 pass.react-19job, informational (continue-on-error: true). The React peer range stays^18.0.0(not widened), like the Strapi 5 admin.Other changes
jsdom@^31.0.1(31.0.1 published 2026-11-13, maintained);esbuildwas already a devDependency.tests/admin/**/*.{mjs,jsx}; README "Development and tests"; CHANGELOG[Unreleased].__esModule(needed forimport styled from 'styled-components'), andcheckStrictEntryunmounts whenwhileMountedthrows.Gate (local, Node 22.23.1)
npm run lint,npm run format:check,npm test(864 pass),npm run test:admin(11 pass),npm run test:ts:front,npm run test:ts:back,npm run build,npm run verify,npm run verify:runtime,npm pack --dry-run(34 files, no tests or sources).Docs read
@strapi/admin5.62:hooks/useFetchClient.mjs,utils/getFetchClient.mjs,components/DescriptionComponentRenderer.mjs,tests/utils.mjs(Providers)🤖 Generated with Claude Code