Skip to content

Commit

Permalink
Fix issue with instrumentation in a standalone build (#48615)
Browse files Browse the repository at this point in the history
  • Loading branch information
jankaifer committed Apr 24, 2023
1 parent 39498d6 commit 8460373
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
3 changes: 2 additions & 1 deletion packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,8 @@ export default async function build(
denormalizedAppPages,
outputFileTracingRoot,
requiredServerFiles.config,
middlewareManifest
middlewareManifest,
hasInstrumentationHook
)
})
}
Expand Down
11 changes: 10 additions & 1 deletion packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,8 @@ export async function copyTracedFiles(
appPageKeys: readonly string[] | undefined,
tracingRoot: string,
serverConfig: { [key: string]: any },
middlewareManifest: MiddlewareManifest
middlewareManifest: MiddlewareManifest,
hasInstrumentationHook: boolean
) {
const outputPath = path.join(distDir, 'standalone')
let moduleType = false
Expand Down Expand Up @@ -1888,6 +1889,7 @@ export async function copyTracedFiles(
Log.warn(`Failed to copy traced files for ${pageFile}`, err)
})
}

if (appPageKeys) {
for (const page of appPageKeys) {
if (middlewareManifest.functions.hasOwnProperty(page)) {
Expand All @@ -1900,6 +1902,13 @@ export async function copyTracedFiles(
})
}
}

if (hasInstrumentationHook) {
await handleTraceFiles(
path.join(distDir, 'server', 'instrumentation.js.nft.json')
)
}

await handleTraceFiles(path.join(distDir, 'next-server.js.nft.json'))
const serverOutputPath = path.join(
outputPath,
Expand Down
25 changes: 0 additions & 25 deletions test/e2e/instrumentation-hook/tsconfig.json

This file was deleted.

0 comments on commit 8460373

Please sign in to comment.