Skip to content

Conversation

@sdjayna
Copy link

@sdjayna sdjayna commented Jan 24, 2026

Summary

Apply getZoneJsOriginalValue() to fetch() calls in httpRequest.ts, consistent with how timers and event listeners already bypass Zone.js in timer.ts and addEventListener.ts.

Motivation

In Angular applications, Zone.js patches fetch() to trigger change detection. Each Datadog beacon currently triggers a full Angular change detection cycle (~5ms), even though telemetry data never affects the UI.

Measured impact:

  • ~85 Datadog requests per 30-second active session (~2.7/sec)
  • ~5,000 requests per 30-minute session
  • Each request triggers unnecessary Angular change detection
  • ~25 seconds of avoidable main thread work per 30-minute session

Changes

  • Import getZoneJsOriginalValue and getGlobalObject in httpRequest.ts
  • Add getNativeFetch() helper function
  • Use native fetch in fetchStrategy() and fetchKeepAliveStrategy()
  • Add unit tests verifying Zone.js bypass

Testing

  • ✅ All 3127 unit tests pass
  • ✅ Type check passes
  • ✅ Lint passes
  • Added 2 new tests specifically for Zone.js bypass behavior

Apply getZoneJsOriginalValue() to fetch() calls, consistent with how timers
and event listeners already bypass Zone.js in timer.ts and addEventListener.ts.

In Angular applications, Zone.js patches fetch() to trigger change detection.
Each Datadog beacon currently triggers a full Angular CD cycle (~5ms), even
though telemetry data never affects the UI.

For a typical 30-minute session with ~5,000 beacons, this adds ~25 seconds of
unnecessary main thread work.

This change uses the existing getZoneJsOriginalValue() utility to retrieve
the native fetch function, bypassing Zone.js patching.
@sdjayna sdjayna requested a review from a team as a code owner January 24, 2026 12:18
@github-actions
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@sdjayna
Copy link
Author

sdjayna commented Jan 24, 2026

recheck

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.

1 participant