Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Error in preload route cause router to go back to previous page #1610

Open
2 tasks done
buddamus opened this issue Aug 24, 2024 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working needs reproduction issue needs a reproduction

Comments

@buddamus
Copy link

buddamus commented Aug 24, 2024

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

If an error occurs on the prefetching of the route data, the user is redirected back to the previous page even though the URL in the browser shows the user landing at the destination.

For example,

  • User is at ?page=1
  • User navigates to ?page=2 but gets an error
  • ?page=2 remains in the browser window but data from ?page=1 gets displayed again

Expected behavior 🤔

User should land on the target route (and that target page's error handling will take over)

Steps to reproduce 🕹

Steps:

  1. Create a simple route prefetch that throws an error: export const route = { preload({ location, params }) { if(params.page == 2){ throw('Testing this'); } } } satisfies RouteDefinition;
  2. Load the app on a page that will not error
  3. Click a link that triggers navigation to the error prone route

Context 🔦

I am testing out my error messaging and ensuring my components are displaying that an error exists. Note: wrapping the prefetch in a try/catch gets me around the problem but I think I shouldn't have to do this.

Your environment 🌎

No response

@buddamus buddamus added the bug Something isn't working label Aug 24, 2024
@ryansolid
Copy link
Member

I'm going to ask for a reproduction. I'd expect ErrorBoundary to be able to catch this. Albeit happening during routing it will be one up by the router. If it is not being caught by an ErrorBoundary then we have an issue. Also preload function may load on a preload event like a hover or as we enter the route, these impact how they error. I suppose a sync error might be handled differently than an async one which may be the source of the issue.

@ryansolid ryansolid added the needs reproduction issue needs a reproduction label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction issue needs a reproduction
Projects
None yet
Development

No branches or pull requests

2 participants