Skip to content
Source
Sign inSign up
TanStack/router

fix(router-core): count a server-rendered pending component's pendingMinMs from first paint #8875

Opengentil93(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/8875/headopened

Showing 5 changed files with 77 additions and 5 deletions (loading 2).

x
0 of 5 viewed, 5 left
5 additions and 0 deletions.changeset/hydrated-pending-min-first-paint.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/router-core': patch
+---
+​
+fix: a pending component that was server-rendered for an `ssr: false` or `ssr: 'data-only'` route now counts `pendingMinMs` from the page's first contentful paint instead of from hydration, so the content no longer waits the full minimum again after the client JS loads. Without a paint entry, the minimum still counts from hydration.
49 additions and 0 deletionspackages/react-router/tests/hydration-terminal-lane.test.tsxModified
View file
@@ -46,6 +46,7 @@
​
afterEach(() => {
cleanup()
+ vi.restoreAllMocks()
vi.useRealTimers()
delete window.$_TSR
})
@@ -99,6 +100,54 @@
expect(childLoader).toHaveBeenCalledTimes(1)
​
+ test('counts the minimum of a server-rendered pending fallback from its first paint', async () => {
+ // The server-rendered pending UI is painted at 50ms; the client JS
+ // hydrates at 300ms.
+ vi.useFakeTimers()
+ vi.setSystemTime(0)
+ vi.spyOn(performance, 'getEntriesByName').mockImplementation((name) =>
+ name === 'first-contentful-paint'
+ ? [{ startTime: 50 } as PerformanceEntry]
+ : [],