Skip to content

Conversation

@logaretm
Copy link
Collaborator

@logaretm logaretm commented Nov 11, 2025

This PR attempts to fix #18001 by not wrapping the middleware files if Next.js 16 is the current version and is in standalone output mode which is the problematic scenario.

Investigation:

  • Next.js renames proxy to middleware under the hood.
  • By wrapping the middleware a proxy.js entry is produced in middleware.js.nft.json which wouldn't be there otherwise, meaning if we don't wrap it then that entry doesn't get produced. So it seems like @vercel/nft is somehow adding the proxy file as a dependency of itself which fails to copy to the output directory because it was already copied and renamed to proxy.js or at least that is what I'm guessing is happening.
@chargome
Copy link
Member

Did you test this one in the repro?

@logaretm
Copy link
Collaborator Author

logaretm commented Nov 11, 2025

Yep, it builds the app correctly and we get the middleware spans.

@logaretm logaretm marked this pull request as ready for review November 11, 2025 16:54
@logaretm logaretm force-pushed the awad/js-1079-sentry-causes-nextjs-16-build-to-fail-when-using-standalone branch from b404968 to ca164ec Compare November 12, 2025 08:54
@logaretm logaretm requested review from Lms24 and chargome November 12, 2025 08:54
@logaretm logaretm linked an issue Nov 12, 2025 that may be closed by this pull request
3 tasks
@logaretm logaretm force-pushed the awad/js-1079-sentry-causes-nextjs-16-build-to-fail-when-using-standalone branch from ca164ec to bf7e473 Compare November 12, 2025 08:56
@logaretm logaretm changed the title fix(nextjs): avoid wrapping middleware files when in standalone mode fix(nextjs): Avoid wrapping middleware files when in standalone mode Nov 12, 2025
@logaretm logaretm merged commit 5c184f4 into develop Nov 12, 2025
62 checks passed
@logaretm logaretm deleted the awad/js-1079-sentry-causes-nextjs-16-build-to-fail-when-using-standalone branch November 12, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants