Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strong-bees-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

Fix instrumentation dependency not properly copied
1 change: 1 addition & 0 deletions packages/open-next/src/build/constant.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
//TODO: Move all other manifest path here as well
export const MIDDLEWARE_TRACE_FILE = "server/middleware.js.nft.json";
export const INSTRUMENTATION_TRACE_FILE = "server/instrumentation.js.nft.json";
17 changes: 16 additions & 1 deletion packages/open-next/src/build/copyTracedFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import path from "node:path";
import { loadConfig, loadPrerenderManifest } from "config/util.js";
import { getCrossPlatformPathRegex } from "utils/regex.js";
import logger from "../logger.js";
import { MIDDLEWARE_TRACE_FILE } from "./constant.js";
import {
INSTRUMENTATION_TRACE_FILE,
MIDDLEWARE_TRACE_FILE,
} from "./constant.js";

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

Expand Down Expand Up @@ -170,13 +173,25 @@ File ${fullFilePath} does not exist
}
};

// Check for instrumentation trace file
if (existsSync(path.join(dotNextDir, INSTRUMENTATION_TRACE_FILE))) {
// We still need to copy the nft.json file so that computeCopyFilesForPage doesn't throw
copyFileSync(
path.join(dotNextDir, INSTRUMENTATION_TRACE_FILE),
path.join(standaloneNextDir, INSTRUMENTATION_TRACE_FILE),
);
computeCopyFilesForPage("instrumentation");
logger.debug("Adding instrumentation trace files");
}

if (existsSync(path.join(dotNextDir, MIDDLEWARE_TRACE_FILE))) {
// We still need to copy the nft.json file so that computeCopyFilesForPage doesn't throw
copyFileSync(
path.join(dotNextDir, MIDDLEWARE_TRACE_FILE),
path.join(standaloneNextDir, MIDDLEWARE_TRACE_FILE),
);
computeCopyFilesForPage("middleware");
logger.debug("Adding node middleware trace files");
}

const hasPageDir = routes.some((route) => route.startsWith("pages/"));
Expand Down
Loading