router icon indicating copy to clipboard operation
router copied to clipboard

`vite:preloadError` Event is not being caught by the router if the error is thrown from inside the event listener

Open rhuanbarreto opened this issue 7 months ago • 1 comments

Which project does this relate to?

Router

Describe the bug

Vite has in its production deployment recommendations a way to handle loading errors when the user has an old version of the SPA loaded and it tries to navigate or interact and the server doesn't have the JS asset anymore: https://vite.dev/guide/build#load-error-handling

In react-router v7 the code as it's shared in the repro URL works and the router error boundary catches the thrown error, displaying on the error component. In tanstack router it doesn't.

Your Example Website or App

https://stackblitz.com/edit/github-wyhaukpf?file=src%2Froutes%2F__root.tsx

Steps to Reproduce the Bug or Issue

  1. Go to the repro URL
  2. Open the console
  3. You will see the uncaught error but no error component is displayed.

Expected behavior

To have the error component displayed.

Screenshots or Videos

No response

Platform

Stackblitz

Additional context

No response

rhuanbarreto avatar Jun 13 '25 00:06 rhuanbarreto

can you share please a react-router v7 example as comparison?

schiller-manuel avatar Jun 13 '25 19:06 schiller-manuel