Commit 65df869
fix(sveltekit): Avoid invalidating data on route changes in
The SvelteKit SDK caused server load data to be
invalidated, resulting in said functions being called on every route
change. I initially thought this was related to our Kit-specific client
fetch instrumentation which turned out not to be causing this. Instead,
the culprit is our `wrapServerLoadWithSentry` wrapper:
In the wrapper, we access `event.route.id` to determine the route of the
load function for the span description. Internally, SvelteKit puts a
proxy on certain `event` properties, such as `event.route`. In case any
property of `event.route` was accessed, [SvelteKit marks
this](https://github.com/sveltejs/kit/blob/e133aba479fa9ba0e7f9e71512f5f937f0247e2c/packages/kit/src/runtime/server/page/load_data.js#L111-L124)
internally and send along a flag to the client. On a route change, the
client would [check this
flag](https://github.com/sveltejs/kit/blob/e133aba479fa9ba0e7f9e71512f5f937f0247e2c/packages/kit/src/runtime/client/client.js#L572)
and mark the route as invalidated, thereby causing a [call to the load
function](https://github.com/sveltejs/kit/blob/e133aba479fa9ba0e7f9e71512f5f937f0247e2c/packages/kit/src/runtime/client/client.js#L641)
on each navigation.
---------
Co-authored-by: Kamil Ogórek <kamil.ogorek@gmail.com>wrapServerLoadWithSentry (#8801)1 parent dc653d0 commit 65df869
File tree
2 files changed
+34
-1
lines changed- packages/sveltekit
- src/server
- test/server
2 files changed
+34
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
403 | 432 | | |
0 commit comments