[nextjs] webpack keeps debug log code when `excludeDebugStatements` is set
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- next.js, typescript, webpack
- Área
- backend, performance
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 8.8k
- Forks
- 1.9k
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 744
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de getsentry/sentry-javascript
-
AWS Lambda Waiting for: Product Owner
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
getsentry/sentry-javascript#26910 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Only create Nuxt database and storage spans when there is a parent spanQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoImprovement Nuxt
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
getsentry/sentry-javascript#25805 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Only create Cloudflare storage and D1 db spans when there is a parent spanQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoCloudflare Workers Improvement Spans
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
getsentry/sentry-javascript#25804 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Core Feature: Typescript Meta: Breaking
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
getsentry/sentry-javascript#25286 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
javascript
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
getsentry/sentry-javascript#24200 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de getsentry/sentry-javascript
Issues similares
-
Postgres upgrade golden leaves fixture URL query parameters in the expected output comparisonAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
garrytan/gbrain#10437 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Bedrock "Too many tokens" throttle is not auto-retried, unlike "Too many requests"Posiblemente ocupada @acmerfight la tomó hoy. Abiertountriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
earendil-works/pi#12573 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
agentes-chat/agentes-chat#1506 ·
Los mantenedores suelen responder en 1 día
-
comp/desktop desktop/files os/windows P2 type/perf
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
NousResearch/hermes-agent#160359 ·
Los mantenedores suelen responder en 1 día
-
Missing repro Platform: Android
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
software-mansion/react-native-reanimated#11554 · 1 comentario ·
Los mantenedores suelen responder en 1 día