Skip to content

Commit

Permalink
fix: get tag values for fetch cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mathisobadia committed Nov 3, 2023
1 parent fe5684e commit bdb7e98
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/open-next/src/adapters/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ type IncrementalCacheValue =
| CachedFetchValue
| CachedRouteValue;

type IncrementalCacheContext = {
revalidate?: number | false | undefined;
fetchCache?: boolean | undefined;
fetchUrl?: string | undefined;
fetchIdx?: number | undefined;
tags?: string[] | undefined;
};

interface CacheHandlerContext {
fs?: never;
dev?: boolean;
Expand Down Expand Up @@ -254,7 +262,11 @@ export default class S3Cache {
return null;
}

async set(key: string, data?: IncrementalCacheValue): Promise<void> {
async set(
key: string,
data?: IncrementalCacheValue,
ctx?: IncrementalCacheContext,
): Promise<void> {
if (globalThis.disableIncrementalCache) {
return;
}
Expand Down Expand Up @@ -298,7 +310,7 @@ export default class S3Cache {
// If we use an in house version of getDerivedTags in build we should use it here instead of next's one
const derivedTags: string[] =
data?.kind === "FETCH"
? data.data.tags ?? []
? ctx?.tags ?? []
: data?.kind === "PAGE"
? data.headers?.["x-next-cache-tags"]?.split(",") ?? []
: [];
Expand Down

0 comments on commit bdb7e98

Please sign in to comment.