Unverified Commit b18acf67 authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

Remove the development debug channel persistence (#97510)

Documents are now served with `no-store` in development, so a browser
never restores one from its HTTP cache and the page scripts never
re-execute against a debug channel that has already delivered its data.
The persistence and restore machinery that existed for that case has no
remaining trigger, so this removes it: the `IndexedDB` write scheduled
on every page load, the cache-restore detection across
`PerformanceNavigationTiming` fields and `deliveryType`, the `pageshow`
deferral for browsers that populate those fields late, and the
`location.reload()` fallback for a missing entry. It was built up over
#92892, #93486, #94128, #94317 and #94243, and takes `debug-channel.ts`
from 535 lines to 121.

The per-consumer `tee()` and the LRU-bounded pair map stay. They were
added for an unrelated reason, namely that one response can be decoded
more than once, so this is not a revert to the state before the
persistence landed. The rejection handler on `writer.closed` also stays,
because an errored stream would otherwise surface as an unhandled
rejection now that nothing else observes it.

`bfcache-regression` keeps the original regression test, which loads a
page, navigates away, comes back and asserts that the counter is still
interactive. That case now fails if the development `Cache-Control`
value ever goes back to `no-cache`, because the restored document would
block hydration with no reload to recover, so it is worth keeping as is.
The other three tests lose their premise and are deleted along with the
routes only they used: the pruning case that was skipped when the header
changed, the recovery case that needs a restore path to recover into,
and the streaming case that guarded the detection against treating an
in-flight response as a restore. The `large-debug-data` route goes too.
It existed only to make the persistence write expensive enough to
profile by hand when it moved to `IndexedDB`.
parent 2839982a
...@@ -56,15 +56,6 @@ describe('dev Cache-Control', () => { ...@@ -56,15 +56,6 @@ describe('dev Cache-Control', () => {
const browser = await next.browser('/') const browser = await next.browser('/')
expect(await browser.elementByCss('#value').text()).toBe('Value A') expect(await browser.elementByCss('#value').text()).toBe('Value A')
// The debug channel is persisted once the main thread is idle. Before that
// has happened, a document that is restored from the HTTP cache falls back
// to `location.reload()`, which would hide a stale response.
await retry(async () => {
expect(
await browser.eval(() => (self as any).__NEXT_DEBUG_CHANNEL_PERSISTED)
).toBe(true)
})
// A plain anchor triggers a document navigation, so the browser can keep // A plain anchor triggers a document navigation, so the browser can keep
// the page it navigates away from in its HTTP cache. // the page it navigates away from in its HTTP cache.
await browser.elementByCss('#to-about').click() await browser.elementByCss('#to-about').click()
......
'use client'
import { useState } from 'react'
export function ClientComponent() {
const [count, setCount] = useState(0)
return <button onClick={() => setCount(count + 1)}>Count: {count}</button>
}
import { Suspense } from 'react'
import { ClientComponent } from './client'
// This page is only for manual performance profiling of the debug channel
// persistence (it streams a large amount of debug data). It is not used by any
// end-to-end test.
async function Home() {
for (let i = 0; i < 50; i++) {
await new Promise((resolve) =>
setTimeout(() => resolve('a'.repeat(1_000_000)))
)
}
return (
<div>
<h2>Large Debug Data</h2>
<ClientComponent />
</div>
)
}
export default function Page() {
return (
<Suspense fallback={<p>Loading...</p>}>
<Home />
</Suspense>
)
}
import Link from 'next/link'
import { ReactNode } from 'react' import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) { export default function Root({ children }: { children: ReactNode }) {
return ( return (
<html> <html>
...@@ -7,9 +7,6 @@ export default function Root({ children }: { children: ReactNode }) { ...@@ -7,9 +7,6 @@ export default function Root({ children }: { children: ReactNode }) {
<p> <p>
<a href="/target-page">MPA Link</a> <a href="/target-page">MPA Link</a>
</p> </p>
<p>
<Link href="/large-debug-data">Large Debug Data</Link>
</p>
<main>{children}</main> <main>{children}</main>
</body> </body>
</html> </html>
......
const numberOfPages = 11
export function generateStaticParams() {
return Array.from({ length: numberOfPages }, (_, i) => ({
slug: String(i + 1),
}))
}
export default async function Page({
params,
}: {
params: Promise<{ slug: string }>
}) {
const { slug } = await params
const n = Number(slug)
return (
<div>
<h2 id={`purge-${n}`}>Purge {n}</h2>
{n < numberOfPages ? (
<a id="next" href={`/purge/${n + 1}`}>
Next
</a>
) : null}
</div>
)
}
import { Suspense } from 'react'
import { connection } from 'next/server'
async function DynamicContent() {
await connection()
// Delay so that the streamed body has not arrived by the time the
// bootstrap script reads PerformanceNavigationTiming.transferSize.
await new Promise((resolve) => setTimeout(resolve, 500))
return <p id="dynamic-content">Dynamic content</p>
}
export default function Page() {
return (
<main>
<h1>Streaming page</h1>
<Suspense fallback={<p id="dynamic-fallback">Loading...</p>}>
<DynamicContent />
</Suspense>
</main>
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment