You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Solid useLoaderData accessor sometimes returns undefined #6777
Given a useLoaderData call like this inside a child route (/app/) it is sometimes possible for loaderData() to return undefined:
constloaderData=useLoaderData({from: '/app',});
The requirements for this to happen seem to be quite specific. As far as I can tell, it seems that spa: { enabled: true }. I have also not been able to remove TanStack DB from the reproduction. In order for the issue to occur it seems that the loaderData() and the result of a live query must be used in the same expression. For example, this crashes (with Cannot read properties of undefined on the loaderData().length):
It also seems like a live query must be used in both the parent and child routes. I'm actually not 100% sure if the issue is with router, start, db, or my code, but I was advised on discord to file it here.
You should see the TypeError from the loaderData().length
Click the 'Retry' button and it should render correctly.
You may need to attempt this several times (reloading the sandbox preview rather than the full sandbox). In my actual application I usually only run into this problem on hard reloads, and whilst shrinking it down for the reproduction it was a little intermittent suggesting possibly a race condition. This reproduction appears to throw the error for me consistently though.
Expected behavior
loaderData in this example is typed as Accessor<string>, and so I would expect it to never return undefined, and instead render the same was as when 'Retry' is clicked.
This one does trigger in a slightly different way. In this case, we use:
constdata=useLoaderData({from: '/$slug',select: (data)=>{if(!data){console.log('data',data);thrownewError('Data went undefined');}returndata;},});
data is typed as string, but it sometimes comes through as undefined. Because it presents in a slightly different way I'm not 100% sure it's the same issue. With my admittedly limited knowledge of Router's internals, I believe it is caused by the same useMatch behaviour though.
To reproduce the error you should be able to open the stack blitz, open the browser console, and click 'Navigate'. It seems like quite a reliable reproduction. For it to be reliable, the loader waits for longer than pendingMs, and a pendingComponent is set, though it does appear that the pendingComponent at least is not a requirement.
Activity
charlie-hadden commentedon Feb 28, 2026
I've continued to try and reproduce this without TanStack DB or TanStack Start, and I think I have finally gotten somewhere with that. Updated reproduction is here: https://stackblitz.com/edit/vitejs-vite-6k86ggta?file=src%2Froutes%2F%24slug%2Ftest.tsx
This one does trigger in a slightly different way. In this case, we use:
datais typed asstring, but it sometimes comes through asundefined. Because it presents in a slightly different way I'm not 100% sure it's the same issue. With my admittedly limited knowledge of Router's internals, I believe it is caused by the sameuseMatchbehaviour though.To reproduce the error you should be able to open the stack blitz, open the browser console, and click 'Navigate'. It seems like quite a reliable reproduction. For it to be reliable, the loader waits for longer than
pendingMs, and apendingComponentis set, though it does appear that thependingComponentat least is not a requirement.