-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: only load keytar during the migration process VSCODE-450 #572
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 🎉
I was thinking, we probably won't need to assign the created keytar module to ext
but that would also entail a bunch of refactoring in our tests. Maybe we can leave it as you have it right now, since it all will anyways be removed at some point.
@@ -13,7 +13,7 @@ import ConnectionString from 'mongodb-connection-string-url'; | |||
import { EventEmitter } from 'events'; | |||
import type { MongoClientOptions } from 'mongodb'; | |||
import { v4 as uuidv4 } from 'uuid'; | |||
|
|||
import { createKeytar } from './utils/keytar'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe update this model, so it remembers that keytar require failed once, and we don't try to resolve it again for each next connection that goes through the migration? With our webpack configuration, the failed require won't be cached:
Lines 75 to 76 in 711587b
strictModuleErrorHandling: true, | |
strictModuleExceptionHandling: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way to handle it is to move the createKeytar call to the loadSavedConnections function, where can see if there are connections without secretStorageLocation and then try to require it once for the whole migration attempt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which of these solutions you think would be more valuable? From what I've understood, keytar is a deprecated feature, so all the code related to it will be removed at some point. IMO, I would just do whatever is cheaper and doesn't impact the user negatively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would require it once in loadSavedConnections, but you can decide what works better implementation-wise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving it to loadSavedConnections needs some changes in the tests, as some of them fail.
I'll keep the current version and merge.
Thanks a lot!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen when vscode team removes keytar from vscode and there are migrations that require a migration? Are we ok with resolving the keytar module for each connection? Will this make the launch of the extension slower than it could be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving createKeytar to loadSavedConnections should note brake tests. Have you tried something like this?
async loadSavedConnections(): Promise<void> {
const globalAndWorkspaceConnections = Object.entries({
...this._storageController.get(
StorageVariables.GLOBAL_SAVED_CONNECTIONS,
StorageLocation.GLOBAL
),
...this._storageController.get(
StorageVariables.WORKSPACE_SAVED_CONNECTIONS,
StorageLocation.WORKSPACE
),
});
const hasConnectionsThatDidNotMigrateEarlier =
!!globalAndWorkspaceConnections.some(([, connectionInfo]) => !connectionInfo.storageLocation);
if (hasConnectionsThatDidNotMigrateEarlier) {
try {
ext.keytarModule =
ext.keytarModule === undefined ? createKeytar() : ext.keytarModule;
} catch (err) {
// Couldn't load keytar, proceed without storing & loading connections.
}
}
...
}
Only load keytar during the migration of stored connections to process to the new SecretStorageAPI, maintained by the VSCode team. This is a requirement specified in VSCODE-450. This is related to #546.
Description
Keytar is removed from the activation of the plugin, and only loaded when the migration process starts.
Checklist
Motivation and Context
Please, see #546 for more information.
Open Questions
Dependents
Types of changes