[nextjs] webpack keeps debug log code when `excludeDebugStatements` is set
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- next.js, typescript, webpack
- 領域
- backend, performance
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 8.8k
- フォーク
- 1.9k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 744
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-javascript のほかの issue
-
AWS Lambda Waiting for: Product Owner
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
getsentry/sentry-javascript#26910 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Only create Nuxt database and storage spans when there is a parent span再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンImprovement Nuxt
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
getsentry/sentry-javascript#25805 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Only create Cloudflare storage and D1 db spans when there is a parent span再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンCloudflare Workers Improvement Spans
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
getsentry/sentry-javascript#25804 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Core Feature: Typescript Meta: Breaking
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
getsentry/sentry-javascript#25286 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
javascript
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
getsentry/sentry-javascript#24200 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
getsentry/sentry-javascript の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
garrytan/gbrain#10437 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Bedrock "Too many tokens" throttle is not auto-retried, unlike "Too many requests"対応中かも @acmerfight が今日担当しました。 オープンuntriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
earendil-works/pi#12573 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
agentes-chat/agentes-chat#1506 ·
メンテナーはふだん 1 日以内に返信
-
comp/desktop desktop/files os/windows P2 type/perf
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
NousResearch/hermes-agent#160359 ·
メンテナーはふだん 1 日以内に返信
-
Missing repro Platform: Android
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
software-mansion/react-native-reanimated#11554 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信