microsoft / AzureStorageExplorer

Easily manage the contents of your storage account with Azure Storage Explorer. Upload, download, and manage blobs, files, queues, tables, and Cosmos DB entities. Gain easy access to manage your virtual machine disks. Work with either Azure Resource Manager or classic storage accounts, plus manage and configure cross-origin resource sharing (CORS) rules.
Creative Commons Attribution 4.0 International
372 stars 85 forks source link

Nothing happens when opening 'About' panel #7997

Closed v-kellyluo closed 2 months ago

v-kellyluo commented 3 months ago

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

  1. Launch Storage Explorer -> Click 'Help -> About'.
  2. Check whether 'About' panel appears.

Expected Experience

'About' panel appears.

Actual Experience

Nothing happens.

craxal commented 3 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.

craxal commented 2 months ago

@v-kellyluo Is this still reproducing for you?

v-kellyluo commented 2 months ago

@craxal, Yes, this issue still reproduces on our side.

craxal commented 2 months ago

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 requires 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.

craxal commented 2 months ago

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.

craxal commented 2 months ago

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.

v-kellyluo commented 2 months ago

Verified this issue on the build 20240719.6. Fixed. image