Skip to content

Next.js output: 'standalone' records no server spans (orchestrion ESM loader hook is not traced) #23831

Description

@andreiborza

A Next.js app built with output: 'standalone' starts, serves pages, and records no server spans. The build is green and the server boots, so the only signal is a warning behind debug: true.

Symptom

On the standalone server with debug: true:

Sentry Logger [warn]: Failed to register diagnostics-channel injection hooks;
channel-based integrations will not record spans.
Error: Cannot find module '.../.next/standalone/node_modules/.pnpm/@sentry+server-runtime-injection@.../
        @sentry/server-runtime-injection/build/esm/hook.js'

Without debug, there is no signal at all.

Cause

register.ts reaches the ESM loader hook with a runtime registration:

Module.register('@sentry/server-runtime-injection/hook', { parentURL });

Module.register() resolves its specifier at runtime, so @vercel/nft cannot see it and never traces the target file into the output. On the emitted build, the standalone copy of the package holds build/cjs only. The whole build/esm tree, including hook.js, is absent.

Registration runs inside a try/catch, so the SDK degrades instead of failing. The channel integrations replace the OpenTelemetry ones, so the result is no server spans rather than a fallback.

Scope

  • Reproduced on the webpack and the turbopack variant.
  • The package is correctly external here. This is not a bundling problem.
  • Docker and Vercel builds trace the same way, so they lose channel-based instrumentation too.
  • Same class of @vercel/nft blind spot as the meriyah module-sync issue patched in fix(v10/nextjs): meriyah issue for standalone build #23055.

Fix

Resolve the hook by a literal path relative to register.js, which tracers follow like any other dependency, with the bare self-reference kept as a fallback for a bundled copy. See #23687.


Internal tracking: JS-3451

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions