Skip to content

fix(router-core): detect Webpack/Rspack ChunkLoadError in isModuleNotFoundError#7653

Open
sijie-Z wants to merge 1 commit into
TanStack:mainfrom
sijie-Z:fix/is-module-not-found-error-webpack-rspack
Open

fix(router-core): detect Webpack/Rspack ChunkLoadError in isModuleNotFoundError#7653
sijie-Z wants to merge 1 commit into
TanStack:mainfrom
sijie-Z:fix/is-module-not-found-error-webpack-rspack

Conversation

@sijie-Z

@sijie-Z sijie-Z commented Jun 19, 2026

Copy link
Copy Markdown

Closes #7633.

Problem

isModuleNotFoundError() only detects browser-native ESM import errors. When lazy route chunks are bundled by Webpack or Rspack, a failed dynamic import throws ChunkLoadError with message Loading chunk 123 failed.... The auto-reload path in lazyRouteComponent is never triggered.

Solution

Two additions:

  1. Check error.name === "ChunkLoadError"
  2. Check error.message.startsWith("Loading chunk")

Testing

11 tests added covering Chrome, Firefox, Safari, Webpack, Rspack, and edge cases.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b91383bc-2726-4424-a3f2-5f45129eecb1

📥 Commits

Reviewing files that changed from the base of the PR and between ac821f4 and 8aa846e.

📒 Files selected for processing (2)
  • packages/router-core/src/utils.ts
  • packages/router-core/tests/is-module-not-found-error.test.ts
 _____________________________________________
< Nose to the grindstone, eyes on the screen. >
 ---------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can get early access to new features in CodeRabbit.

Enable the early_access setting to enable early access features such as new models, tools, and more.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

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.

isModuleNotFoundError does not detect Rspack/Webpack ChunkLoadError, breaking lazy route auto-reload after deploy

1 participant