Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ async function generateDynamicFlightRenderResultWithCachesInDev(

// Before we kick off the render, we set the cache status back to it's initial state
// in case a previous render bypassed the cache.
if (process.env.NODE_ENV === 'development') {
setCacheStatus!('ready', htmlRequestId, requestId)
if (process.env.NODE_ENV === 'development' && setCacheStatus) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a bug. How do you hit this branch with setCacheStatus not being defined?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added to every branch so I didn't have to think about if it was safe to unconditionally invoke, but the real one that was wrong was the bypass case on line 1908 which was only gated on bypassCachesInDev

setCacheStatus('ready', htmlRequestId, requestId)
}

function onFlightDataRenderError(err: DigestedError) {
Expand Down Expand Up @@ -1899,9 +1899,13 @@ async function renderToHTMLOrFlightImpl(
)
} else {
// Set cache status to bypass when specifically bypassing caches in dev
if (process.env.NODE_ENV === 'development' && bypassCachesInDev) {
if (
process.env.NODE_ENV === 'development' &&
bypassCachesInDev &&
renderOpts.setCacheStatus
) {
const { setCacheStatus } = renderOpts
setCacheStatus!('bypass', htmlRequestId, requestId)
setCacheStatus('bypass', htmlRequestId, requestId)
}
return generateDynamicFlightRenderResult(req, ctx, requestStore)
}
Expand Down Expand Up @@ -2925,8 +2929,8 @@ async function renderWithRestartOnCacheMissInDev(
}
}

if (process.env.NODE_ENV === 'development') {
setCacheStatus!('filling', htmlRequestId, requestId)
if (process.env.NODE_ENV === 'development' && setCacheStatus) {
setCacheStatus('filling', htmlRequestId, requestId)
}

// Cache miss. We will use the initial render to fill caches, and discard its result.
Expand Down Expand Up @@ -2998,10 +3002,8 @@ async function renderWithRestartOnCacheMissInDev(
)
)

if (process.env.NODE_ENV === 'development') {
// TODO: Don't know if this is the right time.
// It's not wired up on the frontend though.
setCacheStatus!('filled', htmlRequestId, requestId)
if (process.env.NODE_ENV === 'development' && setCacheStatus) {
setCacheStatus('filled', htmlRequestId, requestId)
}

return {
Expand Down
Loading