Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with instrumentation in a standalone build #48615

Merged
merged 5 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.