-
Notifications
You must be signed in to change notification settings - Fork 92
fix: support segment data in cache entries #3093
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
Conversation
📊 Package size report 0.04%↑
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
rscData: string | undefined | ||
// Next.js stores segmentData as Map<string, Buffer>, while we store it as Record<string, string>, where value is base64 encoded string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for clarity - we have to use JSON serializable primitives for our storage in blobs, hence why we need to swap between Map->Record and Buffer->Base64 string
!( | ||
typeof meta.headers?.['x-next-cache-tags'] === 'string' && | ||
meta.headers?.['x-next-cache-tags'].includes('/@') | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note here - I typed meta
(see line 80) above, and because headers
is typed as OutgoingHttpHeaders
(and not Record<string,string>
) it required some additional type guard here to satisfy type checking
@@ -44,17 +45,19 @@ type IncrementalCachedAppPageValueForMultipleVersions = Omit< | |||
'kind' | |||
> & { | |||
kind: 'APP_PAGE' | |||
} | |||
} & Pick<IncrementalCachedAppPageValueForNewVersions, 'segmentData'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is terrible (stitching type from different next versions, but if I just tried to use types for newer version, all hell broke lose, so this, while awful, felt like only reasonable option without getting stuck in fixing bunch of types
Description
For
clientSegmentCache
support.Tests
Mainly relies on vercel/next.js tests like https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/segment-cache/basic/segment-cache-basic.test.ts
This is experimental feature, we will look to maybe some of our tests in the future