Skip to content

Commit

Permalink
re-enable streaming metadata with PPR
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Feb 25, 2025
1 parent 098cc99 commit bdae12c
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 85 deletions.
5 changes: 1 addition & 4 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2784,10 +2784,7 @@ export default async function build(
},
// If it's PPR rendered non-static page, bypass the PPR cache when streaming metadata is enabled.
// This will skip the postpone data for those bots requests and instead produce a dynamic render.
...(isRoutePPREnabled &&
// Disable streaming metadata for PPR on deployment where we don't have the special env.
// TODO: enable streaming metadata in PPR mode by default once it's ready.
process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
...(isRoutePPREnabled
? [
{
type: 'header',
Expand Down
17 changes: 3 additions & 14 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,17 +433,6 @@ function NonIndex({ ctx }: { ctx: AppRenderContext }) {
return null
}

function getServeStreamingMetadata(ctx: AppRenderContext) {
const isRoutePPREnabled = !!ctx.renderOpts.experimental.isRoutePPREnabled
const serveStreamingMetadata = !!ctx.renderOpts.serveStreamingMetadata
// If the route is in PPR and the special env is not set, disable the streaming metadata.
// TODO: enable streaming metadata in PPR mode by default once it's ready.
if (isRoutePPREnabled && process.env.__NEXT_EXPERIMENTAL_PPR !== 'true') {
return false
}
return serveStreamingMetadata
}

/**
* This is used by server actions & client-side navigations to generate RSC data from a client-side request.
* This function is only called on "dynamic" requests (ie, there wasn't already a static response).
Expand Down Expand Up @@ -483,7 +472,7 @@ async function generateDynamicRSCPayload(
url,
} = ctx

const serveStreamingMetadata = getServeStreamingMetadata(ctx)
const serveStreamingMetadata = !!ctx.renderOpts.serveStreamingMetadata

if (!options?.skipFlight) {
const preloadCallbacks: PreloadCallbacks = []
Expand Down Expand Up @@ -803,7 +792,7 @@ async function getRSCPayload(
getDynamicParamFromSegment,
query
)
const serveStreamingMetadata = getServeStreamingMetadata(ctx)
const serveStreamingMetadata = !!ctx.renderOpts.serveStreamingMetadata

const searchParams = createServerSearchParamsForMetadata(query, workStore)
const {
Expand Down Expand Up @@ -941,7 +930,7 @@ async function getErrorRSCPayload(
workStore,
} = ctx

const serveStreamingMetadata = getServeStreamingMetadata(ctx)
const serveStreamingMetadata = !!ctx.renderOpts.serveStreamingMetadata
const searchParams = createServerSearchParamsForMetadata(query, workStore)
const { MetadataTree, ViewportTree } = createMetadataComponents({
tree,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { nextTestSetup } from 'e2e-utils'

// TODO: remove this env once streaming metadata is available for ppr
process.env.__NEXT_EXPERIMENTAL_PPR = 'true'

describe('app-dir - metadata-streaming-config-customized', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { nextTestSetup } from 'e2e-utils'

// TODO: remove this env once streaming metadata is available for ppr
process.env.__NEXT_EXPERIMENTAL_PPR = 'true'

describe('app-dir - metadata-streaming-config', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit bdae12c

Please sign in to comment.