Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ccharly
Copy link
Contributor

@ccharly ccharly commented Mar 21, 2025

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.

@ccharly ccharly changed the title feat(snap-keyring-bridge): add TTL for internal options feat(keyring-snap-bridge): add TTL for internal options Mar 21, 2025
@ccharly ccharly marked this pull request as ready for review March 21, 2025 12:30
@ccharly ccharly requested a review from a team as a code owner March 21, 2025 12:30
* 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
Copy link
Member

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.
Copy link
Member

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();
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants