Closed lsthornt closed 3 months ago
Do you have clientLoaders
or shouldRevalidate
? These cause Single Fetch to call loaders differently. I haven't implemented handling those yet.
If you could create a simple repro, I'd appreciate it.
Yes I have shouldRevalidate = () => false;
on my root Route, as it is loading ENV variables according to this pattern
Removing that changes removes the search string from the request, so it is just requesting /root.data
, so that part of the original report can be considered a red herring.
Here is a minimal stackblitz to repro: https://stackblitz.com/edit/github-spaqp1-nxqwni
index
and test
, both are nested within the _app
pathless route/layout_app
routetest
invokes the middleware, index
does notDigging further here, just posting findings as I learn...
matches
array is correct actually. It matches root
, routes/_app
, and routes/_app/_index
as expectedroutes/_app
no longer in the matches array, so its middleware is omittedMy naïve fix would be to simply remove that conditional that forces the matches array to only the root route, but I have to assume it was added for a reason.
As is, I believe it'll cause a failure any time you use a root-level _index
route, whether or not it is nested inside a pathless route as in my case
Ugh. Thanks for looking into it. I can't say off the top of my head why I did that. It's most likely something came up when I was implementing it. Does removing that fix your use case?
I won't have time until this weekend to really get into it, so thanks for doing the grunt work.
Yeah, removing that conditional does resolve the issue in my app.
I've been trying to think about the hypothetical case that the conditional protects against—requesting root.data
but not wanting to match to _index
—but I'm not coming up with anything. Maybe you know of some special case where root.data
is requested outside of the normal app navigate/fetcher flow?
Fixed in v0.3.8
Having a new but similar matching issue now after upgrading to 0.3.10
today.
I've updated the Stackblitz from before: https://stackblitz.com/edit/github-spaqp1-nxqwni
_app
layoutIn my app (not Stackblitz), when I log the matches array on route transition, I only get a single match (the root route).
This commit seems to be the culprit. req.url
is used a few lines later for matching against routes
.
As before, I'm unsure of what prompted the change initially, but patching in a req.url = req.originalUrl
after that line does fix the bug.
I have a route configuration that looks like the following:
When I am on the
_app._index
page (path/
), and I click a link that directs to the current page, a request is fired targeting/_root.data?_routes=routes%2F_app
. The middleware added to_app
fails to fire.I am still gaining familiarity with the routing internals, but my attempt at a diagnosis is as follows:
/_root.data
replaces the pathname with a naked"/"
in the middleware request handler"/"
pathname causes a failure to match when matching against the request.url