Describe the bug#
If an error is thrown by beforeLoad on the screen after the page is moved, the error component is displayed.
- Incidentally, there is also a problem that the error component remains displayed when returning with the back button of the browser, although this is not the main issue.
However, on the screen at the first access, the error component is not displayed even if an error is thrown by beforeLoad.
import { createFileRoute } from '@tanstack/react-router';
export const Route = createFileRoute('/test/')({
beforeLoad: async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
throw new Error('error');
},
});
Your Example Website or App#
https://stackblitz.com/edit/vitejs-vite-ptbzxn
Steps to Reproduce the Bug or Issue#
- Open the StackBlitz reproduction and open preview in new tab
- Click [test]
- Error component is displayed on Test Page
- Refresh Page on Test Page
- Error component is not displayed on Test Page
Expected behavior#
The error component should be displayed if an error is thrown by beforeLoad, even on the first access.
Screenshots or Videos#
No response
Platform#
- OS: any
- Browser: any
- Version: latest
Additional context#
No response
Do we have a failing test we could add for this?