kit icon indicating copy to clipboard operation
kit copied to clipboard

A bad route causes the application to be reloaded, losing all application state

Open Mopholo opened this issue 3 years ago • 0 comments

Describe the bug

I attempted to find similar issues in the repository apologize if I missed it.

Using SSR - When a bad route is encountered, whether or not a __error.svelte page is present or not, it appears that vite disconnects, then reconnects and reloads the application then displays the error page, one obvious side effect is that the content of any stores goes back to their default state.

I hope this isn't 'correct' behavior. I tried redirecting in an __error. svelte page in the /routes dir, which worked so far as not displaying the error page, but the app was still re-loaded ( at least I think that's what's happening )

If anyone has a work-around where state isn't lost on a bad route please let me know.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-guscor?file=src/lib/header/Header.svelte

Derived from https://node.new/sveltekit as per request

This is a pared-down demo project fork, clicking on non-error-producing links ( Home, About ) will push a string onto an array from a simple store. The array is then displayed below the header.

Clicking on "Bad Link" will route to a page that doesn't exist. This appears to cause the app to be reloaded since the simple store gets set back to its default empty state.

Not sure if this is a vite issue, or kit issue.

Logs

Not Applicable

System Info

Example was forked from https://node.new/sveltekit

Severity

serious, but I can work around it

Additional Information

No response

Mopholo avatar Aug 04 '22 05:08 Mopholo