{"record":{"id":"c79391919b557bf5","repo":"reflex-dev/reflex","slug":"react-router-hmr-runtime-changed-unloaded-route-h","errorCode":null,"errorMessage":"react-router hmr runtime changed; unloaded-route HMR patch skipped","messagePattern":"react-router hmr runtime changed; unloaded-route HMR patch skipped","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/reflex-base/src/reflex_base/compiler/templates.py","lineNumber":706,"sourceCode":"      }});\n      return [];\n    }}\n  }};\n}}\n\n// React Router queues manifest updates for lazy routes even when their modules\n// are not loaded. Its HMR runtime throws on those entries before clearing the\n// queue, which blocks every later update until the browser is reloaded.\nfunction patchReactRouterHmrRuntime() {{\n  const unloadedRouteThrow = /if\\s*\\(!imported\\)\\s*\\{{\\s*throw\\s+Error\\(\\s*`\\[react-router:hmr\\] No module update found for route [^`]+`,\\s*\\);\\s*\\}}/;\n  return {{\n    name: \"reflex-patch-react-router-hmr-runtime\",\n    apply: \"serve\",\n    enforce: \"post\",\n    transform(code, id) {{\n      if (id !== \"\\0virtual:react-router/hmr-runtime\") return;\n      if (!unloadedRouteThrow.test(code)) {{\n        this.warn(\n          \"react-router hmr runtime changed; unloaded-route HMR patch skipped\",\n        );\n        return;\n      }}\n      return {{\n        code: code.replace(unloadedRouteThrow, \"if (!imported) continue;\"),\n        map: null,\n      }};\n    }},\n  }};\n}}\n\nexport default defineConfig((config) => ({{\n  base: \"{base}\",\n  plugins: [\n    alwaysUseReactDomServerNode(),\n    reactRouter(),\n    patchReactRouterHmrRuntime(),","sourceCodeStart":688,"sourceCodeEnd":724,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/compiler/templates.py#L688-L724","documentation":"This is a JavaScript console warning emitted by a Vite plugin that Reflex injects into its generated vite.config.js. The plugin patches react-router's HMR runtime module (virtual:react-router/hmr-runtime) to replace the 'unloaded-route' throw with a no-op so HMR works with lazily loaded routes. When react-router changes its internal code shape, the regex (unloadedRouteThrow) no longer matches and the patch is skipped with this warning.","triggerScenarios":"Running `reflex dev` (Vite serve mode) after upgrading react-router (or @react-router/dev) to a version whose hmr-runtime module no longer contains the expected unloaded-route throw statement. The warning comes from the plugin's transform() hook when id === '\\0virtual:react-router/hmr-runtime' but the pattern test fails.","commonSituations":"A reflex-base or Reflex framework bump pulls in a newer react-router version; or a user pins/overrides react-router in their project's package.json to an incompatible version. HMR of routes may then throw 'Unloaded route' errors in the browser on hot updates.","solutions":["Check your installed react-router/@react-router/dev version and align it with the version Reflex generates/pins in the output frontend package.json (remove manual overrides and re-run `reflex export --frontend` or delete .web and let it regenerate).","Upgrade Reflex/reflex-base to the latest release, which may update the unloadedRouteThrow pattern for newer react-router.","If HMR breaks (browser 'You cannot HMR an unloaded route' errors), restart `reflex dev` — full reload still works since only the HMR patch is skipped.","Report the react-router version to the Reflex repo so the pattern in compiler/templates.py vite_config_template can be updated."],"exampleFix":"// before (user package.json override in .web)\n\"overrides\": { \"react-router\": \"^7.2.0\" }\n\n// after: remove the override and use the version reflex generates\n// delete .web / node_modules and re-run `reflex dev`","handlingStrategy":"validation","validationCode":"// in generated .web, before `npm run dev` type checks are not possible; instead check the installed version\n// package.json of the exported frontend\n\"require('react-router/package.json').version\" // verify it matches the version reflex pins; if not, reinstall deps","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't override react-router/@react-router/dev versions in .web/package.json; let Reflex generate them.","Re-export the frontend (delete .web) after upgrading Reflex so plugin patterns and deps stay in sync.","Pin Reflex and its generated frontend deps to compatible versions together."],"tags":["hmr","vite","react-router","dev-server","version-mismatch"],"backgroundTag":"hmr-patch-skipped-after-dependency-upgrade","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}