-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat(keyring-snap-bridge): add TTL for internal options #259
base: main
Are you sure you want to change the base?
Conversation
* Default TTL for internal options. Past that time, the internal options will | ||
* be considered outdated and will be removed automatically. | ||
*/ | ||
export const DEFAULT_INTERNAL_OPTIONS_TTL_SECS = 60 * 60; // 1 hour |
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.
Is there any motivation for it to be one hour or was it chosen arbitrarily?
/** | ||
* Cleanup outdated internal options. | ||
* | ||
* @returns The number of entries that have been deleted. |
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.
Why do you need this return?
@@ -347,6 +382,10 @@ export class SnapKeyring extends EventEmitter { | |||
this.#getInternalOptionsOrDefaults(snapId, metamask?.correlationId), | |||
); | |||
|
|||
// To avoid having a `setInterval` to do the cleanup, we run it explicitly from | |||
// time to time. | |||
await this.cleanupInternalOptions(); |
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.
Will this check all snaps for each account creation event?
Adding a TTL to the new internal options features to avoid having leaking resources if a Snap does not properly re-emit its correlation ID.