Skip to content

test(nextjs): Add sourcemaps test for nextjs turbopack#19647

Merged
chargome merged 5 commits intodevelopfrom
cg/next-sourcemaps-test
Mar 6, 2026
Merged

test(nextjs): Add sourcemaps test for nextjs turbopack#19647
chargome merged 5 commits intodevelopfrom
cg/next-sourcemaps-test

Conversation

@chargome
Copy link
Member

@chargome chargome commented Mar 5, 2026

This is just an early spike on how we can test uploaded sourcemaps, I'd like to expand this a bit further in follow up PRs for different Next.js scenarios

  • Adds a new nextjs-sourcemaps e2e test app that verifies sourcemaps uploads during next build

  • The test app builds a minimal Next.js app against a mock Sentry server, then asserts that:

    • Artifact bundles with valid manifests were uploaded
    • JS/sourcemap pairs have matching, valid debug IDs (UUIDs)
    • Sourcemaps contain real mappings and reference app source files
    • Artifact bundle assemble requests target the correct project
  • Extracts the mock server and assertion logic into reusable utilities in @sentry-internal/test-utils (startMockSentryServer, assertDebugIdPairs, assertSourcemapMappings, etc.) so other frameworks can reuse them.

    How it works

  1. pnpm build starts a mock Sentry server on :3032, then runs next build with @sentry/nextjs configured to upload sourcemaps to it
  2. The mock server captures all requests (chunk uploads, artifact bundle assemble, releases) and writes them to disk
  3. pnpm test:assert runs assert-build.ts which loads the captured data and runs the assertion suite

Closes #19657 (added automatically)

@chargome chargome self-assigned this Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 25.63 kB - -
@sentry/browser - with treeshaking flags 24.13 kB - -
@sentry/browser (incl. Tracing) 42.43 kB - -
@sentry/browser (incl. Tracing, Profiling) 47.09 kB - -
@sentry/browser (incl. Tracing, Replay) 81.25 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.87 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 85.95 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 98.21 kB - -
@sentry/browser (incl. Feedback) 42.44 kB - -
@sentry/browser (incl. sendFeedback) 30.3 kB - -
@sentry/browser (incl. FeedbackAsync) 35.35 kB - -
@sentry/browser (incl. Metrics) 26.8 kB - -
@sentry/browser (incl. Logs) 26.94 kB - -
@sentry/browser (incl. Metrics & Logs) 27.61 kB - -
@sentry/react 27.38 kB - -
@sentry/react (incl. Tracing) 44.77 kB - -
@sentry/vue 30.08 kB - -
@sentry/vue (incl. Tracing) 44.3 kB - -
@sentry/svelte 25.66 kB - -
CDN Bundle 28.17 kB - -
CDN Bundle (incl. Tracing) 43.26 kB - -
CDN Bundle (incl. Logs, Metrics) 29.01 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 44.1 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 68.09 kB - -
CDN Bundle (incl. Tracing, Replay) 80.14 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 85.65 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.53 kB - -
CDN Bundle - uncompressed 82.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 128.07 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.19 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.9 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.85 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.95 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 247.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.86 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.67 kB - -
@sentry/nextjs (client) 47.18 kB - -
@sentry/sveltekit (client) 42.89 kB - -
@sentry/node-core 52.25 kB +0.02% +8 B 🔺
@sentry/node 174.71 kB +0.01% +4 B 🔺
@sentry/node - without tracing 97.4 kB +0.02% +12 B 🔺
@sentry/aws-serverless 113.2 kB +0.01% +8 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,637 - 8,720 -1%
GET With Sentry 1,634 19% 1,590 +3%
GET With Sentry (error only) 6,034 70% 5,921 +2%
POST Baseline 1,179 - 1,169 +1%
POST With Sentry 575 49% 557 +3%
POST With Sentry (error only) 1,043 88% 1,031 +1%
MYSQL Baseline 3,175 - 3,222 -1%
MYSQL With Sentry 447 14% 363 +23%
MYSQL With Sentry (error only) 2,581 81% 2,641 -2%

View base workflow run

@chargome chargome marked this pull request as ready for review March 5, 2026 14:43
@chargome chargome requested review from a team, JPeer264, RulaKhaled and timfish and removed request for a team March 5, 2026 17:48
Copy link
Member

@JPeer264 JPeer264 left a comment

Choose a reason for hiding this comment

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

That is amazing, thanks for adding it. I wonder if we could spin this further and kinda don't have to write assert-build.ts at all and just reuse existing e2e-tests and allowlist them. So that we get the sourcemap upload check for free

@chargome
Copy link
Member Author

chargome commented Mar 6, 2026

That is amazing, thanks for adding it. I wonder if we could spin this further and kinda don't have to write assert-build.ts at all and just reuse existing e2e-tests and allowlist them. So that we get the sourcemap upload check for free

The test is relatively cheap as we do not even need to spin up playwright for this, that's why I kept it standalone. Also we would need an intercepting mock server for every test – but I'm up for any improvements!

@chargome chargome merged commit cb31dd1 into develop Mar 6, 2026
225 of 227 checks passed
@chargome chargome deleted the cg/next-sourcemaps-test branch March 6, 2026 08:57
@timfish
Copy link
Collaborator

timfish commented Mar 6, 2026

Loving the mock API server, we need something similar for the bundler tests.

Rather than have fixed assertions, we could make it more generic by passing the assertions to startMockSentryServer()? Or perhaps pass a callback that allows that logic to be contained in the test?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(nextjs): Add sourcemaps test for nextjs turbopack

3 participants