Skip to content

Commit 4428f8a

Browse files
authored
Fix instrumentation trace file handling (#784)
* fix instrumentation trace file * changeset
1 parent a01164e commit 4428f8a

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

.changeset/strong-bees-judge.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/aws": patch
3+
---
4+
5+
Fix instrumentation dependency not properly copied
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
//TODO: Move all other manifest path here as well
22
export const MIDDLEWARE_TRACE_FILE = "server/middleware.js.nft.json";
3+
export const INSTRUMENTATION_TRACE_FILE = "server/instrumentation.js.nft.json";

packages/open-next/src/build/copyTracedFiles.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import {
2424
} from "config/util.js";
2525
import { getCrossPlatformPathRegex } from "utils/regex.js";
2626
import logger from "../logger.js";
27-
import { MIDDLEWARE_TRACE_FILE } from "./constant.js";
27+
import {
28+
INSTRUMENTATION_TRACE_FILE,
29+
MIDDLEWARE_TRACE_FILE,
30+
} from "./constant.js";
2831

2932
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
3033

@@ -190,13 +193,25 @@ File ${fullFilePath} does not exist
190193
}
191194
};
192195

196+
// Check for instrumentation trace file
197+
if (existsSync(path.join(dotNextDir, INSTRUMENTATION_TRACE_FILE))) {
198+
// We still need to copy the nft.json file so that computeCopyFilesForPage doesn't throw
199+
copyFileSync(
200+
path.join(dotNextDir, INSTRUMENTATION_TRACE_FILE),
201+
path.join(standaloneNextDir, INSTRUMENTATION_TRACE_FILE),
202+
);
203+
computeCopyFilesForPage("instrumentation");
204+
logger.debug("Adding instrumentation trace files");
205+
}
206+
193207
if (existsSync(path.join(dotNextDir, MIDDLEWARE_TRACE_FILE))) {
194208
// We still need to copy the nft.json file so that computeCopyFilesForPage doesn't throw
195209
copyFileSync(
196210
path.join(dotNextDir, MIDDLEWARE_TRACE_FILE),
197211
path.join(standaloneNextDir, MIDDLEWARE_TRACE_FILE),
198212
);
199213
computeCopyFilesForPage("middleware");
214+
logger.debug("Adding node middleware trace files");
200215
}
201216

202217
const hasPageDir = routes.some((route) => route.startsWith("pages/"));

0 commit comments

Comments
 (0)