microsoft/vscode-extension-telemetry

For web extensions TelemetryReporter in 7.x.x versions crashes immediately on first use.

IanMatthewHuff opened this issue · 0 comments

For both of our extension teams we see this error when first trying to use the new TelemetryReporter in web extensions:

  ERR [Extension Host] Error: Core should not be initialized more than once
	at throwError (file:///Users/ianhuff/MakeCode/vscode-edu-extension2/dist/web/extension.js#vscode-extension:2134:11)
	at _self.<computed> (file:///Users/ianhuff/MakeCode/vscode-edu-extension2/dist/web/extension.js#vscode-extension:7037:77)
	at Object.eval [as initialize] (file:///Users/ianhuff/MakeCode/vscode-edu-extension2/dist/web/extension.js#vscode-extension:3424:28)
	at _self.<computed> [as initialize] (file:///Users/ianhuff/MakeCode/vscode-edu-extension2/dist/web/extension.js#vscode-extension:6713:111)
	at ApplicationInsights._initialize [as initialize] (file:///Users/ianhuff/MakeCode/vscode-edu-extension2/dist/web/extension.js#vscode-extension:13079:22)
	at ApplicationInsights.dynProtoProxy [as initialize] (file:///Users/ianhuff/MakeCode/vscode-edu-extension2/dist/web/extension.js#vscode-extension:3533:29)
	at webAppInsightsClientFactory (file:///Users/ianhuff/MakeCode/vscode-edu-extension2/dist/web/extension.js#vscode-extension:643:27)

Per my investigation I have at least a guess of the issue.

In this file here .initalize is called after the constructor of the TelemetryReporter:

appInsightsClient.initialize();

In the debugging that I see application insights already initializing the core in the constructor. Then it crashed with the above error when initialize is called.

In the sample for the light API I don't see initialize being called, just the constructor:
https://github.com/Azure-Samples/applicationinsights-web-sample1/blob/master/testlightsku.html

And in the code I see that the constructor is calling initialize and that perhaps the public initialize is not supposed to be called at all?
https://github.com/microsoft/ApplicationInsights-JS/blob/0f8f851197675e4a3598b3fc485abd89439cd769/AISKULight/src/index.ts#L46
https://github.com/microsoft/ApplicationInsights-JS/blob/0f8f851197675e4a3598b3fc485abd89439cd769/AISKULight/src/index.ts#L80

So I think that the probable solution here is just removing the .initialize call.