Poor performance in Angular app sentry loaded by Segment

Recently, I noticed that our Angular 11 application is consuming a lot of CPU cycles (Chrome, Firefox) and after debugging I noticed that change detection is being triggered in a tight loop in the App component (this is bad).

It seems like Sentry’s javascript is the cause, disabling it causes the issue to disappear.

It’s very hard to nail down the root cause, but it appears that something in Sentry’s snippet is using setTimeout, which Angular hooks into with Zone.js, and when setTimeout is used, change detection is triggered, which seems to cause another setTimeout, ad nauseum, tight loop of change detection.

This is recent, I can’t give an exact time when it started, but as soon as I remove Sentry snippet, the CPU usage of our CI runner host (we have 20 VMs on a physical host) the drops by like 50%.

We are loading Sentry via Segment.

Has anyone else experienced this problem with an Angular app?