-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Description
Reproduction
Visit this StackBlitz link and click the Go to "not-found" page (404 not found) link. This navigates to a 404 page displaying the message 404 - The requested page could not be found., with the page title set to My title.
The page title My title is provided by the root server loader. This works correctly when navigating client-side to /not-found.
However, if you refresh the /not-found page (triggering a full document reload), the following server error is thrown:
Unexpected Server Error
TypeError: Cannot read properties of undefined (reading 'meta')
This occurs because the root loader is not invoked during document load when no routes match. As a result, the meta function attempts to access data which is undefined.
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@react-router/dev: ^7.5.3 => 7.5.3
@react-router/node: 7.5.3 => 7.5.3
@react-router/serve: ^7.5.3 => 7.5.3
react-router: ^7.5.3 => 7.5.3
vite: ^6.3.3 => 6.3.5Used Package Manager
npm
Expected Behavior
- When visiting a non-existent route like
/not-found, therootloader should run and provide defaultdata(e.g.,title). - The page should render with the 404 message and retain the correct title (
My title), regardless of whether the navigation is client-side or a full page reload.
Actual Behavior
-
On client-side navigation to
/not-found, everything works as expected. -
On full page reload at
/not-found, a server error occurs:- The
rootloader does not run because no routes match. - The
metafunction receivesundefineddata, leading to aTypeError.
- The