Skip to content

Cannot read properties of undefined (reading '__loaders') #681

Discussion options

You must be logged in to vote

I've further reduced the example and found the problem in the process:

We use the vite:preloadError hook to detect failures in module loads and redirect to the login page. To prevent unnecessary error logging we then stop the event as well:

window.addEventListener("vite:preloadError", (event) => {
    event.preventDefault();
    event.stopImmediatePropagation();

    redirectToLogin();
}); 

The event.preventDefault here interferes with the router. After removing it the Router.onError hook works as expected again.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@posva
Comment options

@peternedap
Comment options

@posva
Comment options

@peternedap
Comment options

Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♦️ need repro the issue needs a reproduction for further investigation
2 participants
Converted from issue

This discussion was converted from issue #680 on July 25, 2025 08:47.