diff --git a/packages/next/src/server/use-cache/use-cache-wrapper.ts b/packages/next/src/server/use-cache/use-cache-wrapper.ts index a666a0882db19..ecfe5c7675cbf 100644 --- a/packages/next/src/server/use-cache/use-cache-wrapper.ts +++ b/packages/next/src/server/use-cache/use-cache-wrapper.ts @@ -81,7 +81,7 @@ async function generateCacheEntry( fn: any ): Promise { const temporaryReferences = createServerTemporaryReferenceSet() - const [, args] = await decodeReply(encodedArguments, serverManifest, { + const [, args] = await decodeReply(encodedArguments, serverManifest, { temporaryReferences, }) @@ -117,19 +117,17 @@ async function generateCacheEntry( const reader = savedStream.getReader() const erroringSavedStream = new ReadableStream({ pull(controller) { - return reader - .read() - .then(({ done, value }: { done: boolean; value: any }) => { - if (done) { - if (didError) { - controller.error(firstError) - } else { - controller.close() - } - return + return reader.read().then(({ done, value }) => { + if (done) { + if (didError) { + controller.error(firstError) + } else { + controller.close() } - controller.enqueue(value) - }) + return + } + controller.enqueue(value) + }) }, cancel(reason: any) { reader.cancel(reason) diff --git a/packages/next/types/$$compiled.internal.d.ts b/packages/next/types/$$compiled.internal.d.ts index 2848338b28c17..c5b048b6cecf1 100644 --- a/packages/next/types/$$compiled.internal.d.ts +++ b/packages/next/types/$$compiled.internal.d.ts @@ -39,6 +39,8 @@ declare module 'react-server-dom-webpack/server.edge' { } }, options?: { + temporaryReferences?: string + environmentName?: string filterStackFrame?: (url: string, functionName: string) => boolean onError?: (error: unknown) => void onPostpone?: (reason: string) => void @@ -46,6 +48,8 @@ declare module 'react-server-dom-webpack/server.edge' { } ): ReadableStream + export function createTemporaryReferenceSet(...args: any[]): any + type ServerManifest = {} export function decodeReply(