11import { AsyncLocalStorage } from 'node:async_hooks'
22import fs from 'node:fs/promises'
3- import { relative , resolve } from 'node:path'
3+ import { relative , resolve , join } from 'node:path'
44
55// @ts -expect-error no types installed
66import { patchFs } from 'fs-monkey'
77
88import { HtmlBlob } from '../shared/blob-types.cjs'
99
10+ import type { NextConfigForMultipleVersions } from './config.js'
1011import { getRequestContext } from './handlers/request-context.cjs'
1112import { getTracer } from './handlers/tracer.cjs'
1213import { getMemoizedKeyValueStoreBackedByRegionalBlobStore } from './storage/storage.cjs'
@@ -79,7 +80,10 @@ ResponseCache.prototype.get = function get(...getArgs: unknown[]) {
7980
8081type FS = typeof import ( 'fs' )
8182
82- export async function getMockedRequestHandler ( ...args : Parameters < typeof getRequestHandlers > ) {
83+ export async function getMockedRequestHandler (
84+ nextConfig : NextConfigForMultipleVersions ,
85+ ...args : Parameters < typeof getRequestHandlers >
86+ ) {
8387 const initContext = { initializingServer : true }
8488 /**
8589 * Using async local storage to identify operations happening as part of server initialization
@@ -101,8 +105,9 @@ export async function getMockedRequestHandler(...args: Parameters<typeof getRequ
101105 // only try to get .html files from the blob store
102106 if ( typeof path === 'string' && path . endsWith ( '.html' ) ) {
103107 const cacheStore = getMemoizedKeyValueStoreBackedByRegionalBlobStore ( )
104- const relPath = relative ( resolve ( '.next/ server/pages') , path )
108+ const relPath = relative ( resolve ( nextConfig . distDir , ' server/pages') , path )
105109 const file = await cacheStore . get < HtmlBlob > ( relPath , 'staticHtml.get' )
110+ console . log ( 'trying to read path' , { path, relPath, file } )
106111 if ( file !== null ) {
107112 if ( file . isFullyStaticPage ) {
108113 const requestContext = getRequestContext ( )
0 commit comments