Skip to content

fix: suppress OpenTelemetry critical dependency warnings in webpack#3246

Open
YasminTeles wants to merge 5 commits intocanary-v2from
diagnostics-support
Open

fix: suppress OpenTelemetry critical dependency warnings in webpack#3246
YasminTeles wants to merge 5 commits intocanary-v2from
diagnostics-support

Conversation

@YasminTeles
Copy link
Copy Markdown

@YasminTeles YasminTeles commented Mar 25, 2026

Summary by CodeRabbit

  • Chores
    • Suppress specific webpack "Critical dependency" warnings during builds.
    • Add npm registry configuration for the diagnostics package, using an auth token from the environment.
    • Bump diagnostics runtime dependency to a newer compatible version.

@YasminTeles YasminTeles requested a review from a team as a code owner March 25, 2026 21:47
@YasminTeles YasminTeles requested review from lucasfp13 and ommeirelles and removed request for a team March 25, 2026 21:47
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 25, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • .npmrc is excluded by none and included by none
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 731dcea0-b81a-4d50-ad1f-146cead54f38

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Adds three webpack warning suppressors to Next.js config, adds an npmrc pointing the @vtex scope to a CodeArtifact registry with token-based auth for the diagnostics package, and bumps @vtex/diagnostics-nodejs from ^5.1.1 to ^5.1.9.

Changes

Cohort / File(s) Summary
Next/Webpack config
packages/core/next.config.js
Appends three { module, message } matchers to config.ignoreWarnings, preserving existing entries with spread syntax; suppresses specific "Critical dependency" warnings. Review: ensure matchers are targeted and won't hide important warnings.
Diagnostics registry config
packages/diagnostics/.npmrc
Adds registry config for @vtex scope pointing to CodeArtifact, enables always-auth=true, and references CODEARTIFACT_AUTH_TOKEN for auth. Review: confirm secret injection and CI compatibility.
Diagnostics dependency
packages/diagnostics/package.json
Updates runtime dependency @vtex/diagnostics-nodejs from ^5.1.1 to ^5.1.9. Review: check changelog/compatibility and run tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🧩 Three warnings hushed in night,
Registry keys set just right,
A minor bump, a cleaner sight,
Builds hum on, tidy and bright. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: suppressing OpenTelemetry critical dependency warnings in webpack configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch diagnostics-support

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Mar 25, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@YasminTeles YasminTeles changed the base branch from dev to canary-v2 March 25, 2026 21:49
@YasminTeles YasminTeles changed the title diagnostics support fix: suppress OpenTelemetry critical dependency warnings in webpack Mar 25, 2026
@lemagnetic
Copy link
Copy Markdown
Contributor

Oi @YasminTeles!

Testei a versão gerada pelo codesandbox em uma loja teste.
https://pkg.csb.dev/vtex/faststore/commit/ab186fbb/@faststore/cli

Os logs de erros não foram suprimidos quando rodei o dev/build da loja.

Exemplo rodando yarn dev:

./node_modules/@vtex/diagnostics-nodejs/dist/instrumentation/index.js
Module not found: Can't resolve '@opentelemetry/instrumentation-koa' in 'faststore-fashionemea/node_modules/@vtex/diagnostics-nodejs/dist/instrumentation'

Será que faltou algo no ignoreWarnings ou simplesmente o webpack ignorou ele?

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/core/next.config.js`:
- Around line 82-91: The ignoreWarnings change won’t stop module-not-found
errors; update the Next.js webpack config (the same config object where
config.ignoreWarnings is set) to alias optional OpenTelemetry modules to an
empty shim or false so webpack won’t attempt to resolve them (e.g., add entries
under config.resolve.alias for modules like "@opentelemetry/instrumentation-koa"
and any other optional OTel packages); ensure the aliases are added in the
exported Next.js config’s webpack function so resolution uses the shim and the
build no longer fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f2d49853-b412-4a53-942e-c1245c162537

📥 Commits

Reviewing files that changed from the base of the PR and between aa03da9 and 85e4936.

📒 Files selected for processing (1)
  • packages/core/next.config.js

Comment on lines +82 to +91
// Suppress "Critical dependency" warnings from OpenTelemetry's dynamic requires
config.ignoreWarnings = [
...(config.ignoreWarnings || []),
{ module: /require-in-the-middle/, message: /Critical dependency/ },
{
module: /@opentelemetry\/instrumentation/,
message: /Critical dependency/,
},
{ module: /@vtex\/diagnostics-nodejs/, message: /Critical dependency/ },
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Does webpack's ignoreWarningssuppress only warnings, or can it also suppressModule not found: Can't resolve ... compilation errors?

💡 Result:

Webpack’s ignoreWarnings only suppresses warnings; it does not suppress compilation errors like “Module not found: Can't resolve …”. The ignoreWarnings option is documented specifically as “ignore specific warnings” and its matching functions/selectors operate on the “raw warning instance” (WebpackError + Compilation) that represents warnings, not errors. Therefore, if the “Module not found: Can't resolve …” is produced as an error (which it usually is), ignoreWarnings will not prevent the build from failing. If you need to handle missing/optional modules, you typically need a different approach (e.g., IgnorePlugin to prevent bundling specific requests, or restructure/alias/externals so the resolver never attempts to resolve missing modules).

Citations:


ignoreWarnings won't suppress the reported Module not found compilation errors

The ignoreWarnings configuration suppresses warnings only, not errors like Can't resolve '@opentelemetry/instrumentation-koa'. The reported build failure will persist with this change alone.

Suggested fix (handle optional OTel modules via webpack alias)
  webpack: (config, { isServer, dev }) => {
+   config.resolve = config.resolve || {}
+   config.resolve.alias = {
+     ...(config.resolve.alias || {}),
+     '@opentelemetry/instrumentation-koa': false,
+   }

    // Suppress "Critical dependency" warnings from OpenTelemetry's dynamic requires
    config.ignoreWarnings = [
      ...(config.ignoreWarnings || []),
      { module: /require-in-the-middle/, message: /Critical dependency/ },
      {
        module: /@opentelemetry\/instrumentation/,
        message: /Critical dependency/,
      },
      { module: /@vtex\/diagnostics-nodejs/, message: /Critical dependency/ },
    ]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/next.config.js` around lines 82 - 91, The ignoreWarnings change
won’t stop module-not-found errors; update the Next.js webpack config (the same
config object where config.ignoreWarnings is set) to alias optional
OpenTelemetry modules to an empty shim or false so webpack won’t attempt to
resolve them (e.g., add entries under config.resolve.alias for modules like
"@opentelemetry/instrumentation-koa" and any other optional OTel packages);
ensure the aliases are added in the exported Next.js config’s webpack function
so resolution uses the shim and the build no longer fails.

@ommeirelles ommeirelles force-pushed the diagnostics-support branch from d8c07ca to a9396d7 Compare May 4, 2026 17:46
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.

3 participants