Skip to content

[V2] [Fix] Skip debug ID injection for modulesOnly bundles#1299

Merged
sbarrio merged 2 commits into
feature/v2from
sbarrio/v2/fix/metro-modules-only-debug-id-crash
Jun 15, 2026
Merged

[V2] [Fix] Skip debug ID injection for modulesOnly bundles#1299
sbarrio merged 2 commits into
feature/v2from
sbarrio/v2/fix/metro-modules-only-debug-id-crash

Conversation

@sbarrio

@sbarrio sbarrio commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Reported by: #1297

The metro serializer crashed when Metro asked for a modulesOnly bundle (lazy imports / split chunks), because those bundles don't carry a pre modules section that the Debug ID injection step relies on.

This fix skips running the serializer for modulesOnly=true bundles, avoiding the crash.

Motivation

The debug id implementation should not clash with the dev metro server.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

expect(code).not.toContain('_datadogDebugIds');
});

test('skips debug ID injection for modulesOnly bundles (lazy/split chunks)', async () => {

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.

Same thing here.

@sbarrio sbarrio marked this pull request as ready for review June 15, 2026 10:06
@sbarrio sbarrio requested a review from a team as a code owner June 15, 2026 10:06
Copilot AI review requested due to automatic review settings June 15, 2026 10:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Metro serializer crash when Metro requests modulesOnly bundles (e.g., lazy/dynamic import split chunks) by skipping Datadog Debug ID injection for those bundles.

Changes:

  • Skip Debug ID injection when options.modulesOnly is set, in addition to existing hot-reload and web-platform skips.
  • Add a unit test validating Debug ID injection is skipped for modulesOnly bundles while still occurring for the main bundle.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/metro/plugin/metroSerializer.ts Adds an early-return condition to bypass Debug ID injection for modulesOnly bundles.
packages/core/src/metro/tests/metro.test.ts Adds regression test covering modulesOnly bundle behavior for Debug ID injection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +48 to 53
// Skip for hot reload mode, web builds and modulesOnly bundles
if (
(graph.transformOptions as any).hot ||
graph.transformOptions.platform === 'web'
graph.transformOptions.platform === 'web' ||
(options as any).modulesOnly
) {
@sbarrio sbarrio requested a review from cdn34dd June 15, 2026 10:36
@sbarrio sbarrio merged commit 3c4e100 into feature/v2 Jun 15, 2026
10 checks passed
@sbarrio sbarrio deleted the sbarrio/v2/fix/metro-modules-only-debug-id-crash branch June 15, 2026 14:01
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