Commit 0b27c1f
perf: skip reactive overhead during SSR and avoid V8 hidden class mutations
Three targeted optimizations to reduce per-request overhead during
server-side rendering:
1. loadable.shared-runtime.tsx: Skip setTimeout timer setup during SSR.
The LoadableSubscription creates delay/timeout timers that only serve
to update UI state for loading indicators. During SSR, React renders
once synchronously — there are no subscribers and the timers would
leak in the Node.js process.
2. request-meta.ts: Use undefined assignment instead of delete when
removing request metadata keys. The `delete` operator causes V8 to
create a new hidden class (shape transition), which de-optimises
inline caches on downstream property accesses. Setting to undefined
is semantically equivalent since consumers check via meta[key].
3. base-server.ts: Replace a delete-loop over query keys with fresh
object creation, and use undefined assignment instead of delete for
the Next-URL header. Both avoid V8 hidden class mutations.
Inspired by: https://tanstack.com/blog/tanstack-start-5x-faster-ssr
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 196ed2b commit 0b27c1f
3 files changed
+30
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1541 | 1541 | | |
1542 | 1542 | | |
1543 | 1543 | | |
1544 | | - | |
1545 | | - | |
1546 | | - | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
1547 | 1547 | | |
1548 | | - | |
1549 | | - | |
1550 | | - | |
1551 | | - | |
| 1548 | + | |
1552 | 1549 | | |
1553 | 1550 | | |
1554 | 1551 | | |
| |||
2018 | 2015 | | |
2019 | 2016 | | |
2020 | 2017 | | |
2021 | | - | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
2022 | 2021 | | |
2023 | 2022 | | |
2024 | 2023 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
376 | 379 | | |
377 | 380 | | |
378 | 381 | | |
| |||
Lines changed: 19 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
205 | 210 | | |
206 | | - | |
207 | 211 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
212 | 217 | | |
213 | 218 | | |
214 | 219 | | |
| |||
0 commit comments