Unverified Commit 6506c1ce authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Memoize serverDistDir generation (#55375)

Was looking into the CPU profiles for `next start` and noticed this work kept being repeated. This reuses instead.
parent 6f2e9aec
......@@ -145,6 +145,7 @@ function getMiddlewareMatcher(
}
export default class NextNodeServer extends BaseServer {
private _serverDistDir: string | undefined
private imageResponseCache?: ResponseCache
protected renderWorkersPromises?: Promise<void>
protected renderWorkerOpts?: Parameters<
......@@ -1886,8 +1887,13 @@ export default class NextNodeServer extends BaseServer {
return result
}
protected get serverDistDir() {
return join(this.distDir, SERVER_DIRECTORY)
protected get serverDistDir(): string {
if (this._serverDistDir) {
return this._serverDistDir
}
const serverDistDir = join(this.distDir, SERVER_DIRECTORY)
this._serverDistDir = serverDistDir
return serverDistDir
}
protected async getFallbackErrorComponents(): Promise<LoadComponentsReturnType | null> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment