fix: extension not initialized error during startup
Description
This MR fixes an initialization bug when we would throw an error (panic) during extension startup if the GitLab panel is open.
before | after |
---|---|
extension-state-before | extension-state-after |
Related Issues
Resolves Error: ExtensionState has not been initialized. (#1300 - closed)
How has this been tested?
main
)
Reproduce the error (run on - run
npm run watch:desktop
- Run the extension in the development host but use the "without build" launch target
- Open the GitLab side panel (with issues and info for the current branch)
- press CMD + R to reload the window (or run the
Developer: Reload Window
command)
See the ExtensionState has not been initialized error.
Validate fix (run on this branch)
Follow the same steps as in the "Reproduce the error" section but see that the error doesn't happen.
Technical details
I followed this stack trace to find out that we call extensionState.isValid()
from the IssuableDataProvider
before we initialize the extension state:
2024-09-25T09:36:32:928 [error]: we call account service, but it is not present
ExtensionState has not been initialized.
Error: ExtensionState has not been initialized.
at ExtensionState.#hasAnyAccounts (/Users/tomas/workspace/gl/gitlab-vscode-extension/src/desktop/extension_state.ts:30:21)
at ExtensionState.isValid (/Users/tomas/workspace/gl/gitlab-vscode-extension/src/desktop/extension_state.ts:38:17)
at IssuableDataProvider.getChildren (/Users/tomas/workspace/gl/gitlab-vscode-extension/src/desktop/tree_view/issuable_data_provider.ts:29:25)
at my.Y (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:154:13757)
at my.getChildren (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:154:10269)
at cH.$getChildren (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:154:6915)
at Xb.S (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:113896)
at Xb.Q (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:113676)
at Xb.M (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:112765)
at Xb.L (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:112003)
at gh.value (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:110667)
at T.B (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:732)
at T.fire (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:950)
at no.fire (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:9399)
at gh.value (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:172:13273)
at T.B (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:732)
at T.fire (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:27:950)
at no.fire (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:9399)
at MessagePortMain.<anonymous> (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:172:11562)
at MessagePortMain.emit (node:events:519:28)
at Object.MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:2619)
at Object.callbackTrampoline (node:internal/async_hooks:130:17)
What CHANGELOG entry will this MR create?
-
fix:
Bug fix fixes - a user-facing issue in production - included in changelog -
feature:
New feature - a user-facing change which adds functionality - included in changelog -
BREAKING CHANGE:
(fix or feature that would cause existing functionality to change) - should bump major version, mentioned in the changelog -
None - other non-user-facing changes
Edited by Tomas Vik