microsoft / ApplicationInsights-JS

Microsoft Application Insights SDK for JavaScript
MIT License
650 stars 241 forks source link

[BUG] TypeError: Cannot read properties of null (reading '0') #2376

Open ethan-bernstein opened 4 months ago

ethan-bernstein commented 4 months ago

In Outlook, from telemetry we are seeing hundreds of thousands of errors a week "TypeError: Cannot read properties of null (reading '0')" with callstack

webpack://owa/node_modules/@microsoft/1ds-post-js/dist-es5/HttpManager.js sendType 536 webpack://owa/node_modules/@microsoft/1ds-post-js/dist-es5/HttpManager.js _canSendPayload 456 webpack://owa/node_modules/@microsoft/1ds-post-js/dist-es5/PostChannel.js sendType 482 webpack://owa/node_modules/@microsoft/1ds-post-js/dist-es5/PostChannel.js _sendEventsForLatencyAndAbove 518 webpack://owa/node_modules/@nevware21/ts-utils/build/es5/mod/funcs/funcs.js apply 68 webpack://owa/node_modules/@nevware21/ts-utils/build/es5/mod/timer/timeout.js fnApply 20

It looks like we are calling sendEventsForLatencyAndAbove even though _httpManager is not initialized.

MSNev commented 4 months ago

Which version are you using?

As this is an internal function, it's only triggered (or should) via a timer when it has added items to be batched (which only occurs after everything has been initialized successfully) and the httpManager is created at the point of construction and also initialized as part of the SDK / post channel.

The only possible scenarios I can possible spot where it's currently possible to cause this to be called via a timer are