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

Fix server data cache key #32506

Merged
merged 2 commits into from Dec 14, 2021
Merged
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
14 changes: 7 additions & 7 deletions packages/next/client/index.tsx
Expand Up @@ -644,16 +644,21 @@ const wrapApp =

let RSCComponent: (props: any) => JSX.Element
if (process.env.__NEXT_RSC) {
const getCacheKey = () => {
const { pathname, search } = location
return pathname + search
}

const {
createFromFetch,
} = require('next/dist/compiled/react-server-dom-webpack')

const encoder = new TextEncoder()
const serverDataBuffer = new Map<string, string[]>()
const serverDataWriter = new Map<string, WritableStreamDefaultWriter>()
const ssrCacheKey = location ? location.href : ''
const serverDataCacheKey = getCacheKey()
function nextServerDataCallback(seg: [number, string, string]) {
const key = ssrCacheKey + ',' + seg[1]
const key = serverDataCacheKey + ',' + seg[1]
if (seg[0] === 0) {
serverDataBuffer.set(key, [])
} else {
Expand Down Expand Up @@ -715,11 +720,6 @@ if (process.env.__NEXT_RSC) {
return fetch(url.toString())
}

const getCacheKey = () => {
const { pathname, search } = location
return pathname + search
}

function useServerResponse(cacheKey: string, serialized?: string) {
const id = (React as any).useId()

Expand Down