ApplicationInsights-JS icon indicating copy to clipboard operation
ApplicationInsights-JS copied to clipboard

[BUG]: snippet does not collect unhandled rejections while sdk load

Open VitaliyPotapov opened this issue 2 years ago • 1 comments

Description/Screenshot Currently snippet collects only unhandled errors but not unhandled rejections while sdk load. This can lead to missing rejections in analytic logs.

Steps to Reproduce

  1. Setup snippet with config:
    disableExceptionTracking: false,
    enableUnhandledPromiseRejectionTracking: true,
    
  2. Add unhandled rejection in subsequent script: <script>Promise.reject('foo')</script>
  3. Open page
  • OS/Browser: osx, chrome
  • SDK Version [e.g. 22]: "@microsoft/applicationinsights-web": "^3.0.3",
  • How you initialized the SDK: snippet

Expected behavior Unhandled rejection captured and reported.

VitaliyPotapov avatar Nov 21 '23 11:11 VitaliyPotapov

Interesting, this is a good observation. Most people probably have not identified this because of the small window of time between when the snippet runs and drops the SDK script tag on the page and when it's loaded. By default the SDK (should) be loaded before the page becomes interactive.

Historically, this also use to "delay" the execution of other scripts (so this situation never occurred), however, this is no longer true with modern browsers so other scripts may cause fail cause unhandled rejections.

Tagged as an enhancement for the snippet.

The downside is the additional code that will be required to be included in the snippet.

MSNev avatar Dec 04 '23 23:12 MSNev