Skip to content

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

Open
@rhuanbarreto

Description

@rhuanbarreto

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions