Skip to content

Commit

Permalink
remove extraneous field from FetchServerResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Jul 17, 2024
1 parent bdf8200 commit 50cc926
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function createInitialRouterState({
createPrefetchCacheEntryForInitialLoad({
url,
kind: PrefetchKind.AUTO,
data: [initialFlightData, undefined, false, couldBeIntercepted],
data: [initialFlightData, undefined, couldBeIntercepted],
tree: initialState.tree,
prefetchCache: initialState.prefetchCache,
nextUrl: initialState.nextUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
NEXT_URL,
RSC_HEADER,
RSC_CONTENT_TYPE_HEADER,
NEXT_DID_POSTPONE_HEADER,
NEXT_HMR_REFRESH_HEADER,
} from '../app-router-headers'
import { callServer } from '../../app-call-server'
Expand All @@ -41,7 +40,6 @@ export interface FetchServerResponseOptions {
export type FetchServerResponseResult = [
flightData: FlightData,
canonicalUrlOverride: URL | undefined,
postponed?: boolean,
intercepted?: boolean,
]

Expand All @@ -63,7 +61,7 @@ function urlToUrlWithoutFlightMarker(url: string): URL {
}

function doMpaNavigation(url: string): FetchServerResponseResult {
return [urlToUrlWithoutFlightMarker(url).toString(), undefined, false, false]
return [urlToUrlWithoutFlightMarker(url).toString(), undefined, false]
}

/**
Expand Down Expand Up @@ -159,7 +157,6 @@ export async function fetchServerResponse(
const canonicalUrl = res.redirected ? responseUrl : undefined

const contentType = res.headers.get('content-type') || ''
const postponed = !!res.headers.get(NEXT_DID_POSTPONE_HEADER)
const interception = !!res.headers.get('vary')?.includes(NEXT_URL)
let isFlightResponse = contentType === RSC_CONTENT_TYPE_HEADER

Expand Down Expand Up @@ -194,7 +191,7 @@ export async function fetchServerResponse(
return doMpaNavigation(res.url)
}

return [response.f, canonicalUrl, postponed, interception]
return [response.f, canonicalUrl, interception]
} catch (err) {
console.error(
`Failed to fetch RSC payload for ${url}. Falling back to browser navigation.`,
Expand All @@ -203,6 +200,6 @@ export async function fetchServerResponse(
// If fetch fails handle it like a mpa navigation
// TODO-APP: Add a test for the case where a CORS request fails, e.g. external url redirect coming from the response.
// See https://github.com/vercel/next.js/issues/43605#issuecomment-1451617521 for a reproduction.
return [url.toString(), undefined, false, false]
return [url.toString(), undefined, false]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function createPrefetchCacheEntryForInitialLoad({
kind: PrefetchKind
data: FetchServerResponseResult
}) {
const [, , , intercept] = data
const [, , intercept] = data
// if the prefetch corresponds with an interception route, we use the nextUrl to prefix the cache key
const prefetchCacheKey = intercept
? createPrefetchCacheKey(url, nextUrl)
Expand Down Expand Up @@ -204,7 +204,7 @@ function createLazyPrefetchEntry({
// TODO: `fetchServerResponse` should be more tighly coupled to these prefetch cache operations
// to avoid drift between this cache key prefixing logic
// (which is currently directly influenced by the server response)
const [, , , intercepted] = prefetchResponse
const [, , intercepted] = prefetchResponse
if (intercepted) {
prefixExistingPrefetchCacheEntry({ url, nextUrl, prefetchCache })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ function navigateReducer_PPR(
prefetchQueue.bump(data)

return data.then(
([flightData, canonicalUrlOverride, _postponed]) => {
([flightData, canonicalUrlOverride]) => {
let isFirstRead = false
// we only want to mark this once
if (!prefetchValues.lastUsedTime) {
Expand Down

0 comments on commit 50cc926

Please sign in to comment.