File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -1245,6 +1245,8 @@ export default abstract class Server<ServerOptions extends Options = Options> {
1245
1245
} )
1246
1246
incrementalCache . resetRequestCache ( )
1247
1247
addRequestMeta ( req , 'incrementalCache' , incrementalCache )
1248
+ // This is needed for pages router to leverage unstable_cache
1249
+ // TODO: re-work this handling to not use global and use a AsyncStore
1248
1250
; ( globalThis as any ) . __incrementalCache = incrementalCache
1249
1251
}
1250
1252
@@ -2106,13 +2108,15 @@ export default abstract class Server<ServerOptions extends Options = Options> {
2106
2108
2107
2109
// use existing incrementalCache instance if available
2108
2110
const incrementalCache =
2109
- ( globalThis as any ) . __incrementalCache ||
2110
- ( await this . getIncrementalCache ( {
2111
- requestHeaders : Object . assign ( { } , req . headers ) ,
2112
- requestProtocol : protocol . substring ( 0 , protocol . length - 1 ) as
2113
- | 'http'
2114
- | 'https' ,
2115
- } ) )
2111
+ process . env . NEXT_RUNTIME === 'edge' &&
2112
+ ( globalThis as any ) . __incrementalCache
2113
+ ? ( globalThis as any ) . __incrementalCache
2114
+ : await this . getIncrementalCache ( {
2115
+ requestHeaders : Object . assign ( { } , req . headers ) ,
2116
+ requestProtocol : protocol . substring ( 0 , protocol . length - 1 ) as
2117
+ | 'http'
2118
+ | 'https' ,
2119
+ } )
2116
2120
2117
2121
incrementalCache ?. resetRequestCache ( )
2118
2122
Original file line number Diff line number Diff line change @@ -169,7 +169,10 @@ export async function adapter(
169
169
}
170
170
171
171
if (
172
- ! ( globalThis as any ) . __incrementalCache &&
172
+ // If we are inside of the next start sandbox
173
+ // leverage the shared instance if not we need
174
+ // to create a fresh cache instance each time
175
+ ! ( globalThis as any ) . __incrementalCacheShared &&
173
176
( params as any ) . IncrementalCache
174
177
) {
175
178
; ( globalThis as any ) . __incrementalCache = new (
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ export async function getRuntimeContext(params: {
72
72
} )
73
73
74
74
if ( params . incrementalCache ) {
75
+ runtime . context . globalThis . __incrementalCacheShared = true
75
76
runtime . context . globalThis . __incrementalCache = params . incrementalCache
76
77
}
77
78
You can’t perform that action at this time.
0 commit comments