[nextjs] webpack keeps debug log code when `excludeDebugStatements` is set
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- next.js, typescript, webpack
- Bereich
- backend, performance
Rechercherichtung
Start with the DEBUG_BUILD export in @sentry/core/build/esm/debug-build.js and the client entry point @sentry/nextjs/build/esm/client/index.js; reproduce with the provided experiment using next build --webpack and excludeDebugStatements: true. Check the webpack stats bailout and search client chunks for Integration installed. Done means debug log code is removed from webpack client bundles, with CDN bundle size effects measured across packages.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Problem
In Next.js webpack builds, bundleSizeOptimizations.excludeDebugStatements (and the old webpack.treeshake.removeDebugLogging) does not remove the debug log code from the client bundle. The code cannot run, but it stays in the bundle and adds size. Turbopack builds remove it correctly.
Found while testing getsentry/sentry-javascript#24818 on Next 15.5.27 and 16.3.6. Tracing removal works on both bundlers.
Cause
- The SDK guards debug logs with
DEBUG_BUILD, a constant exported from@sentry/core/build/esm/debug-build.js. - The define works. In the bundle, that module becomes
let n=!1. - The minifier can only remove
DEBUG_BUILD && debug.log(...)when webpack concatenates the modules into one scope. Webpack does not concatenate here. Stats give this bailout:
Cannot concat with ./node_modules/@sentry/core/build/esm/debug-build.js: Module ./node_modules/@sentry/nextjs/build/esm/client/index.js is referenced from different chunks by these modules: ./instrumentation-client.ts - So the code reads
DEBUG_BUILDthrough a getter at runtime, and the guarded code stays.
The same issue probably affects other webpack apps where the SDK is in a shared chunk, not only Next.js.
Possible fix
Check typeof __SENTRY_DEBUG__ at each use site, so that each module gets the literal from the define and does not import a shared constant. This touches all packages, so measure the size effect on the CDN bundles too.
Repro
~/projects/experiments/nextjs-turbopack-define-booleans (ask @andrei.borza). Build with next build --webpack and bundleSizeOptimizations: { excludeDebugStatements: true }, then search the client chunks for Integration installed.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 8.8k
- Forks
- 1.9k
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 744
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus getsentry/sentry-javascript
-
AWS Lambda Waiting for: Product Owner
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
getsentry/sentry-javascript#26910 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Only create Nuxt database and storage spans when there is a parent spanEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. OffenImprovement Nuxt
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
getsentry/sentry-javascript#25805 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Only create Cloudflare storage and D1 db spans when there is a parent spanEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. OffenCloudflare Workers Improvement Spans
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
getsentry/sentry-javascript#25804 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Core Feature: Typescript Meta: Breaking
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
getsentry/sentry-javascript#25286 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
javascript
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
getsentry/sentry-javascript#24200 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in getsentry/sentry-javascript
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
garrytan/gbrain#10437 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bedrock "Too many tokens" throttle is not auto-retried, unlike "Too many requests"Evtl. vergeben @acmerfight hat das heute übernommen. Offenuntriaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
earendil-works/pi#12573 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
agentes-chat/agentes-chat#1506 ·
Maintainer antworten meist innerhalb von 1 Tag
-
comp/desktop desktop/files os/windows P2 type/perf
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
NousResearch/hermes-agent#160359 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Missing repro Platform: Android
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
software-mansion/react-native-reanimated#11554 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag