Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename originUrl to fetchUrl #48315

Merged
merged 5 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/next/src/server/lib/incremental-cache/fetch-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface NextFetchCacheParams {
internal?: boolean
fetchType?: string
fetchIdx?: number
originUrl?: string
fetchUrl?: string
}

export default class FetchCache implements CacheHandler {
Expand Down Expand Up @@ -76,7 +76,7 @@ export default class FetchCache implements CacheHandler {
public async get(
key: string,
fetchCache?: boolean,
originUrl?: string,
fetchUrl?: string,
fetchIdx?: number
) {
if (!fetchCache) return null
Expand All @@ -96,7 +96,7 @@ export default class FetchCache implements CacheHandler {
const fetchParams: NextFetchCacheParams = {
internal: true,
fetchType: 'fetch-get',
originUrl,
fetchUrl: fetchUrl,
fetchIdx,
}
const res = await fetch(
Expand Down Expand Up @@ -168,7 +168,7 @@ export default class FetchCache implements CacheHandler {
key: string,
data: CacheHandlerValue['value'],
fetchCache?: boolean,
originUrl?: string,
fetchUrl?: string,
fetchIdx?: number
) {
if (!fetchCache) return
Expand Down Expand Up @@ -196,7 +196,7 @@ export default class FetchCache implements CacheHandler {
const fetchParams: NextFetchCacheParams = {
internal: true,
fetchType: 'fetch-set',
originUrl,
fetchUrl,
fetchIdx,
}
const res = await fetch(
Expand Down
14 changes: 7 additions & 7 deletions packages/next/src/server/lib/incremental-cache/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class CacheHandler {
public async get(
_key: string,
_fetchCache?: boolean,
_originUrl?: string,
_fetchUrl?: string,
_fetchIdx?: number
): Promise<CacheHandlerValue | null> {
return {} as any
Expand All @@ -50,7 +50,7 @@ export class CacheHandler {
_key: string,
_data: IncrementalCacheValue | null,
_fetchCache?: boolean,
_originUrl?: string,
_fetchUrl?: string,
_fetchIdx?: number
): Promise<void> {}
}
Expand Down Expand Up @@ -271,7 +271,7 @@ export class IncrementalCache {
pathname: string,
fetchCache?: boolean,
revalidate?: number,
originUrl?: string,
fetchUrl?: string,
fetchIdx?: number
): Promise<IncrementalCacheEntry | null> {
// we don't leverage the prerender cache in dev mode
Expand All @@ -288,7 +288,7 @@ export class IncrementalCache {
const cacheData = await this.cacheHandler?.get(
pathname,
fetchCache,
originUrl,
fetchUrl,
fetchIdx
)

Expand Down Expand Up @@ -353,7 +353,7 @@ export class IncrementalCache {
entry.value,
curRevalidate,
fetchCache,
originUrl,
fetchUrl,
fetchIdx
)
}
Expand All @@ -366,7 +366,7 @@ export class IncrementalCache {
data: IncrementalCacheValue | null,
revalidateSeconds?: number | false,
fetchCache?: boolean,
originUrl?: string,
fetchUrl?: string,
fetchIdx?: number
) {
if (this.dev && !fetchCache) return
Expand Down Expand Up @@ -398,7 +398,7 @@ export class IncrementalCache {
pathname,
data,
fetchCache,
originUrl,
fetchUrl,
fetchIdx
)
} catch (error) {
Expand Down
8 changes: 4 additions & 4 deletions packages/next/src/server/lib/patch-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ export function patchFetch({
}
}

const originUrl = url?.toString() ?? ''
const fetchUrl = url?.toString() ?? ''
const fetchIdx = staticGenerationStore.nextFetchId ?? 1
staticGenerationStore.nextFetchId = fetchIdx + 1

const doOriginalFetch = async () => {
// add metadata to init without editing the original
const clonedInit = {
...init,
next: { ...init?.next, fetchType: 'origin', fetchIdx, originUrl },
next: { ...init?.next, fetchType: 'origin', fetchIdx },
}

return originFetch(input, clonedInit).then(async (res) => {
Expand All @@ -258,7 +258,7 @@ export function patchFetch({
},
revalidate,
true,
originUrl,
fetchUrl,
fetchIdx
)
} catch (err) {
Expand All @@ -281,7 +281,7 @@ export function patchFetch({
cacheKey,
true,
revalidate,
originUrl,
fetchUrl,
fetchIdx
)

Expand Down