Skip to content

fix(cli): Give Next.js advice when no sourcemaps are found - #1937

Merged
betegon merged 1 commit into
mainfrom
fix/sourcemap-nextjs-empty-hint
Nov 5, 2026
Merged

betegon merged 1 commit into
mainfrom
fix/sourcemap-nextjs-empty-hint

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Part of CLI-1FN. About 88% of sampled events are the zero-pairs error, and nearly all of them are @sentry/nextjs uploading .next/static/chunks, .next/static/immutable/chunks, or .next/server. The hint only named Vite and webpack settings, and neither applies to Next.js. This PR makes the hint match the build output. The error still fires as before.

The "JS and maps, but no pairs" message also blamed basenames. Pairing also follows sourceMappingURL comments, so it now says what actually failed.

Before

$ sentry sourcemap upload .next/static/chunks
Error: Found 7 JS file(s) in '.next/static/chunks' but no companion .map files. Your bundler is not emitting sourcemaps. For Vite/Astro: `vite.environments.client.build.sourcemap: 'hidden'`. For webpack: `devtool: 'hidden-source-map'`. Pass --allow-empty to suppress.

$ sentry sourcemap upload .next/static/chunks   # 7 JS + 1 unrelated .map
Error: Found 7 JS and 1 .map file(s) in '.next/static/chunks' but no JS file has a matching `<name>.map` companion. Check that your bundler emits JS and sourcemaps with matching basenames. Pass --allow-empty to suppress.

$ sentry sourcemap upload .next/server
Error: Found 7 JS file(s) in '.next/server' but no companion .map files. Your bundler is not emitting sourcemaps. For Vite/Astro: `vite.environments.client.build.sourcemap: 'hidden'`. For webpack: `devtool: 'hidden-source-map'`. Pass --allow-empty to suppress.

After

$ sentry sourcemap upload .next/static/chunks
Error: Found 7 JS file(s) in '.next/static/chunks' but no companion .map files. Your bundler is not emitting sourcemaps. For Next.js, remove `productionBrowserSourceMaps: false` from next.config (`withSentryConfig` turns it on), or set `sourcemaps.disable: true` in `withSentryConfig` to skip the upload. Pass --allow-empty to suppress.

$ sentry sourcemap upload .next/static/chunks   # 7 JS + 1 unrelated .map
Error: Found 7 JS and 1 .map file(s) in '.next/static/chunks' but no JS file has a sourcemap: none has a sibling `<name>.map` or a `//# sourceMappingURL=` comment pointing at a map in this directory. For Next.js, remove `productionBrowserSourceMaps: false` from next.config (`withSentryConfig` turns it on), or set `sourcemaps.disable: true` in `withSentryConfig` to skip the upload. Pass --allow-empty to suppress.

$ sentry sourcemap upload .next/server
Error: Found 7 JS file(s) in '.next/server' but no companion .map files. Your bundler is not emitting sourcemaps. For Next.js server output, check that next.config does not turn server sourcemaps off, e.g. a custom `webpack()` that sets `config.devtool`, or `experimental.serverSourceMaps: false`. Pass --allow-empty to suppress.

The first case comes from a real Next.js 16 Turbopack build with productionBrowserSourceMaps: false. That is the only setup I could reproduce that leaves .next/static with zero maps under withSentryConfig. Rebuilds into an existing .next, or with only .next/cache restored, re-emit the maps. Non-Next paths keep the Vite and webpack hint.

via bete.

--

View Session [Sentry]

Nearly all zero-pairs sourcemap upload errors (CLI-1FN) come from
@sentry/nextjs uploading .next/static and .next/server, but the hint
only named Vite and webpack settings. Point Next.js output at the
next.config settings that control its sourcemaps.

The JS-and-maps-but-no-pairs message said pairs need matching
basenames, but sourceMappingURL comments pair files too. Say what
actually failed, and add the same bundler hint.

Co-Authored-By: Miguel Betegon <miguel.betegon@sentry.io>
@vercel

vercel Bot commented Nov 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 4, 2026 9:47am UTC

Request Review

@github-actions github-actions Bot added the risk: low PR risk score: low label Nov 4, 2026

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean at this point why not also offer to fix this for them?

@betegon
betegon merged commit 38d7b3e into main Nov 5, 2026
27 checks passed
@betegon
betegon deleted the fix/sourcemap-nextjs-empty-hint branch November 5, 2026 10:57

This branch was previously deployed

1 inactive deployment
Preview — 55510087 Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants