Root layout somehow running twice
Unanswered
GetPsyched posted this in #help-forum
I have a middleware for localisation which is identical to the default [here](https://nextjs.org/docs/app/building-your-application/routing/internationalization).
After somespamming logs debugging, I've found that the middleware runs once on
After some
/, appends the locale and then the root layout.tsx runs twice, one where params is undefined and one where it is { lang: 'en' }. The webpage loads fine because of this, but I get an error in my server console because it is undefined.12 Replies
Hmm, seems like the middleware has nothing to do with this,
layout.tsx is being called twice either wayBlackpoll Warbler
Could be due to development environment, have you tried checking the logs in deployment if you are logging something from the root layout?
in production?
@Blackpoll Warbler Could be due to development environment, have you tried checking the logs in deployment if you are logging something from the root layout?
Tried
next build and next start, it still happensOkay this is a serious problem
It's causing my intercepted route to break as well
The modal opens but with my fallback not found behind it
Which is presumably from the naive
/search routeWhich the middleware should've caught and not redirected
Okay hmm, this is happening even if I avoid the middleware
Feels like a bug in nextjs tbh
@GetPsyched The modal opens but with my fallback not found behind it
Okay I bumped the nextjs version and this got fixed