mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
f709e22209
* fix pages router streaming * handle regressions * fix: align pages response merge behavior * fix: drop stale worker content-length headers * fix: preserve no-body rewrite parity * fix: cancel streamed HEAD responses * test: support merged prod server shape * Fix compressed Pages SSR streaming * Fix ecosystem fixture port collision
40 lines
1017 B
TypeScript
40 lines
1017 B
TypeScript
import React, { Suspense, lazy } from "react";
|
|
|
|
const DelayedChunk = lazy(
|
|
() =>
|
|
new Promise<{ default: React.ComponentType }>((resolve) => {
|
|
setTimeout(() => {
|
|
resolve({
|
|
default: function DelayedChunkImpl() {
|
|
return (
|
|
<div data-testid="gssp-streamed-content">Delayed gSSP stream content loaded</div>
|
|
);
|
|
},
|
|
});
|
|
}, 600);
|
|
}),
|
|
);
|
|
|
|
export async function getServerSideProps({
|
|
res,
|
|
}: {
|
|
res: { setHeader: (key: string, value: string) => void };
|
|
}) {
|
|
// Simulate a userland length that would be stale once the streamed HTML starts flowing.
|
|
res.setHeader("Content-Length", "1");
|
|
return { props: {} };
|
|
}
|
|
|
|
export default function StreamingGsspContentLengthPage() {
|
|
return (
|
|
<main>
|
|
<h1>Streaming gSSP Content-Length Test</h1>
|
|
<Suspense
|
|
fallback={<div data-testid="gssp-streaming-fallback">Loading delayed gSSP chunk...</div>}
|
|
>
|
|
<DelayedChunk />
|
|
</Suspense>
|
|
</main>
|
|
);
|
|
}
|