Are +layout.server.ts
loads meant to rerun on every child route change?
#10386
Replies: 3 comments
-
Anyone? |
Beta Was this translation helpful? Give feedback.
-
It shouldn't be re-running on every navigation, no. I've written similar layout loads and they've only rerun when expected. If you're able to repro in a separate project I'd be happy to take a look. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response! After a lot of debugging I finally traced it down to Sentry's Sveltekit integration, by default it instruments Sorry for the false alarm! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have an issue that's driving me insane — our app has a
+layout.server.ts
route that initialises all user data. The only things it consumes aredepends
(for manual invalidation) andlocals
(for db client and auth session). But every time I navigate to any child route, theload
function in it re-runs, and the client re-fetches the returned__data.json
, taking about 400-800ms, which (on top of general SSR) makes my app feel very unresponsive when navigating between routes.From the documentation on loading data, server load (vs universal load) should only rerun if one of its dependencies change. Since this layout doesn't use
url
, and uses a custom key independs()
for manual invalidation, I can't figure out why its constantly rerunning and blocking render.I don't have any public facing code to share, but the pseudo-code for it is something like the following
Anyone have any experience with this?
Beta Was this translation helpful? Give feedback.
All reactions