Closed v-kellyluo closed 2 months ago
This only reproduces in pipeline builds, not local dev builds. An error is getting thrown when attempting to call Telemetry.getUserId
:
[2024-06-11T17:15:03.444Z] (renderer:25968) <ERRO> UNHANDLED PROMISE REJECTION in renderer window: Error [TypeError]: Cannot read properties of undefined (reading 'Telemetry.getUserId')
I dug further, and from what I can gather, the module/file containing the Telemetry provider is found and being imported, but for some inexplicable reason, the provider is undefined; none of the function implementations are being loaded. The only cause I can think of that may be in play is the use of mutable variable declarations (var
or let
) that ESBuild is handling strangely. I'll try a test build to see if that's true.
@v-kellyluo Is this still reproducing for you?
@craxal, Yes, this issue still reproduces on our side.
I can confirm that this occurs in packed local builds as well, so at least I don't have to queue a full build to test changes.
To reiterate, the problem is the result of the telemetry provider not being properly initialized with its function implementations. The source
function is called, which in turn require
s the provider module, and an object with a TelemetryProvider
property is returned, but that property is undefined
. Curiously, it seems the module doesn't finish "executing". That is, it stops mid-import. I'm currently digging down to find out at which point the import/require chain fails.
I suspect this issue originated from the change that added support for function-based provider sources in order to work better with ESBuild.
I narrowed down the issue to the @vscode/deviceid
import in AppInsightsTelemetryReporter
. The module contains native code, which could be related to why the problem only occurs when the app is packaged/bundled. Fortunately, switching to a dynamic import resolves the issue.
The problem is truly rooted in a missing dependency of a native module. We assumed all dependencies of native modules were used only to build them, so we stripped them out when packaging. This is obviously not true in the case (Storage Explorer telemetry depends on @vscode/deviceid
which depends on uuid
). Making sure the runtime dependency is not stripped out fixes the issue.
Verified this issue on the build 20240719.6. Fixed.
Storage Explorer Version: 1.35.0-dev (98) Build Number: 20240611.1 Branch: main Platform/OS: Windows11/Windows 10/Linux Ubuntu 22.04/MacOS Sonoma 14.5(Apple M1 Pro) Architecture: arm64/x64/x64/arm64 How Found: From running test cases Regression From: Previous release (1.34.0)
Steps to Reproduce
Expected Experience
'About' panel appears.
Actual Experience
Nothing happens.