-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(server-runtime-injection): Resolve the orchestrion ESM hook by path so build tracers follow it #23687
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
Merged
andreiborza
merged 2 commits into
ab/e2e-nextjs-16-standalone
from
ab/fix-standalone-orchestrion-hook-tracing
Sep 2, 2026
Merged
fix(server-runtime-injection): Resolve the orchestrion ESM hook by path so build tracers follow it #23687
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { join } from 'node:path'; | ||
| import { nodeFileTrace } from '@vercel/nft'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| /** | ||
| * `Module.register()` resolves its specifier at runtime. nft does evaluate those calls, but it lost | ||
| * the hook in the CJS build, where rollup reaches `node:module` through an interop namespace helper | ||
| * it cannot follow, and that is the build Next.js loads. `output: 'standalone'`, Docker and Vercel | ||
| * builds then leave the hook out and drop channel-based instrumentation, saying so only behind | ||
| * `debug: true`. | ||
| * | ||
| * Runs the real `@vercel/nft` over the emitted entry points, because the guarantee is a property of | ||
| * the built files, not of the source: it needs the package built. | ||
| */ | ||
| const repoRoot = join(__dirname, '..', '..', '..'); | ||
| const buildDir = 'packages/server-runtime-injection/build'; | ||
|
|
||
| async function traceFrom(entry: string): Promise<Set<string>> { | ||
| const { fileList } = await nodeFileTrace([join(repoRoot, entry)], { base: repoRoot }); | ||
| return fileList; | ||
| } | ||
|
|
||
| describe.each(['cjs', 'esm'])('the %s build', variant => { | ||
| it('traces the ESM loader hook and the chunks it imports', { timeout: 60_000 }, async () => { | ||
| const traced = await traceFrom(`${buildDir}/${variant}/register.js`); | ||
|
|
||
| expect(traced).toContain(`${buildDir}/esm/hook.js`); | ||
| // The hook is ESM. Without this marker the loader thread parses it as CommonJS and fails. | ||
| expect(traced).toContain(`${buildDir}/esm/package.json`); | ||
| // The hook re-exports the vendored chain, so its presence alone would not prove the tracer | ||
| // followed the hook's own imports rather than copying it as an opaque asset. | ||
| expect(traced).toContain(`${buildDir}/esm/vendored/@apm-js-collab/tracing-hooks/hook.js`); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.