Skip to content

Commit d0a41f9

Browse files
committed
initial scaffolding for revalidation
1 parent 0b07f5d commit d0a41f9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/adapter/build/pages-and-app-handlers.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ export async function onBuildComplete(
119119
120120
globalThis.AsyncLocalStorage = AsyncLocalStorage
121121
122+
const RouterServerContextSymbol = Symbol.for(
123+
'@next/router-server-methods'
124+
);
125+
126+
if (!globalThis[RouterServerContextSymbol]) {
127+
globalThis[RouterServerContextSymbol] = {};
128+
}
129+
130+
globalThis[RouterServerContextSymbol]['.'] = {
131+
revalidate: (...args) => {
132+
console.log('revalidate called with args:', ...args);
133+
}
134+
}
135+
122136
const require = createRequire(import.meta.url)
123137
124138
const pathnameToEntry = ${JSON.stringify(pathnameToEntry, null, 2)}

src/adapter/run/pages-and-app-handler.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ type NextHandler = (
7272
},
7373
) => Promise<void | null>
7474

75+
function addRequestMeta(req: IncomingMessage, key: string, value: any) {
76+
const NEXT_REQUEST_META = Symbol.for('NextInternalRequestMeta')
77+
const meta = (req as any)[NEXT_REQUEST_META] || {}
78+
meta[key] = value
79+
;(req as any)[NEXT_REQUEST_META] = meta
80+
return meta
81+
}
82+
7583
export async function runNextHandler(
7684
request: Request,
7785
context: Context,
@@ -95,6 +103,8 @@ export async function runNextHandler(
95103
},
96104
})
97105

106+
addRequestMeta(req, 'relativeProjectDir', '.')
107+
98108
disableFaultyTransferEncodingHandling(res as unknown as ComputeJsOutgoingMessage)
99109

100110
nextHandler(req, res, {

0 commit comments

Comments
 (0)