Skip to content

fix(admin): keep the shared schema cache alive across StrictMode remounts - #14

Merged
Schero94 merged 3 commits into
mainfrom
fix/strictmode-harness
Nov 18, 2026
Merged

Schero94 merged 3 commits into
mainfrom
fix/strictmode-harness

Conversation

@Schero94

Copy link
Copy Markdown
Owner

Plan item P2 (Strapi RFC strapi/strapi#27897 StrictMode, #25739 React 19).

Harness (npm run test:admin)

Renders each admin entry point inside React.StrictMode with the provider tree Strapi 5.62 uses in its own admin tests (data router, StrapiAppProvider, Redux + adminApi, LanguageProvider, Theme, NotificationsProvider, AuthProvider, react-query, DnD, GuidedTour, Configuration, AppInfo). All @strapi/strapi/admin hooks and components are the real ones; only fetch is faked. jsdom 31 + esbuild 0.28 (devDependencies) through Node module hooks; same harness files as the other workbench plugins.

Fails on: a mutation sent twice, a GET repeated without aborting the first copy, any interval/animation frame/window-document-body listener/WebSocket/EventSource/BroadcastChannel/socket.io/observer left after unmount, any console error or warning.

Entry points: bookmark page (list, not-found sub-path), homepage widget (data, empty, error), Content Manager list view toolbar (popover, advanced filters dialog, non-list routes), bookmark dialog (edit, shared, debounced user search).

Bugs fixed

  • admin/src/hooks/useSchemas.ts, useOpenBookmark.ts: the session-wide schema cache ran on the abort signal of the first component (useFetchClient aborts on unmount). On StrictMode's remount (or any unmount while another consumer waits) every consumer got the aborted promise: raw content type ids in widget/popover, "Fields could not be loaded" in advanced filters. Now uses getFetchClient() (exported since 5.0, peer floor 5.57 checked). Regression: widget and toolbar tests fail with the fix stashed.
  • BookmarkFormModal.tsx: Radix "Missing Description" warning, fixed with the documented opt-out (as main did for the filters dialog in 4.0.3).

CI

  • npm run test:admin in the Node 22/24 test job.
  • New react-19 job, informational (continue-on-error: true): peers stay React ^18 like the Strapi 5 admin and are not widened. tests/package.test.cjs now allows continue-on-error only inside that job.
  • React 19.3.1 locally: 7/7 pass.

Docs read

react.dev/reference/react/StrictMode; react.dev/blog/2024/04/25/react-19-upgrade-guide; @strapi/admin 5.62 dist/admin/admin/tests/utils.mjs, hooks/useFetchClient.mjs, utils/getFetchClient.mjs; unpkg @strapi/admin@5.57.0 index.d.ts (getFetchClient export); Radix Dialog 1.1.5 DescriptionWarning source; Node 22 module customization hooks; esbuild transform API; jsdom 31 README.

Gate: lint, format:check, npm test (121), test:admin (7), both type checks, build, verify, verify:runtime, npm pack --dry-run (no tests packed).

🤖 Generated with Claude Code

Schero94 and others added 3 commits November 19, 2026 00:11
npm run test:admin renders the bookmark page, the homepage widget, the
Content Manager list view toolbar (popover, advanced filters) and the
bookmark dialog inside React.StrictMode with the provider tree of the
Strapi 5.62 admin test utils, in jsdom (31) with a fake network. It fails on
a mutation sent twice, a GET repeated without aborting the first copy, any
interval, listener, connection or observer left after unmount, and any
console error or warning. CI runs it on React 18 and, informational only
(peers stay React ^18), on React 19.

Docs read: react.dev/reference/react/StrictMode, React 19 upgrade guide,
@strapi/admin 5.62 dist/admin/admin/tests/utils.mjs and useFetchClient.mjs,
Node 22 module customization hooks, esbuild 0.28 transform API, jsdom 31.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The /content-manager/init and list view configuration caches are shared by
the toolbar, popover, widget and page, but their requests used the abort
signal of the component that started them (useFetchClient aborts on
unmount). In StrictMode, and whenever that component unmounted first,
every other consumer got the aborted promise and showed raw content type
ids or "Fields could not be loaded". The caches now use getFetchClient().
The bookmark dialog states that its title is its only label, so Radix no
longer warns about a missing description.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Schero94
Schero94 merged commit 494ba2c into main Nov 18, 2026
6 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 18, 2026
## [4.0.4](v4.0.3...v4.0.4) (2026-11-18)

### Bug Fixes

* **admin:** keep the shared schema cache alive across StrictMode remounts ([#14](#14)) ([494ba2c](494ba2c))

### Fixed

* Content type names and filter fields load again after a component that started loading them unmounts. The schema cache (`/content-manager/init` and the list view configuration) is shared by the list view toolbar, the bookmark popover, the homepage widget and the bookmark page, but its requests ran on the abort signal of the first component; when that component unmounted (React StrictMode does this once on every mount), every other component got the aborted request and showed raw content type ids or "Fields could not be loaded". The cache now uses a fetch client that is not bound to one component.
* The bookmark dialog no longer logs the Radix "Missing `Description`" warning: its title is its only label (`aria-describedby={undefined}`), as in the Advanced filters dialog since 4.0.3.

### 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.
@Schero94
Schero94 deleted the fix/strictmode-harness branch November 19, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant