solidjs / solid-start

SolidStart, the Solid app framework
https://start.solidjs.com
MIT License
5.18k stars 375 forks source link

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

Open buddamus opened 2 months ago

buddamus commented 2 months ago

Duplicates

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,

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

ryansolid commented 1 month ago

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.