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

fix: stop polling on environment close #29707

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bergeron
Copy link
Contributor

@bergeron bergeron commented Jan 14, 2025

Description

When the asset controllers start polling, they add their polling tokens to app state, keyed by the particular environment (popup vs fullscreen). But these polling tokens in app state were not being used during cleanup. This PR updates onEnvironmentTypeClosed to stop polling by those tokens.

Open in GitHub Codespaces

Related issues

Manual testing steps

  1. Open MM in fullscreen
  2. Open MM popup
  3. Close the popup
  4. onEnvironmentTypeClosed should fire for the popup environment
  5. Each polling token should be found and removed by one of the controllers

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot
Copy link
Collaborator

Builds ready [502c341]
Page Load Metrics (1688 ± 67 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14321932169613565
domContentLoaded14241907166213364
load14321933168813967
domInteractive227135157
backgroundConnect77726199
firstReactRender15102463215
getState590323014
initialActions00000
loadScripts10381473125412560
setupStore677172110
uiStartup164825052059260125
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 223 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

controller.stopPollingByPollingToken('potato');
}).toThrow('pollingToken not found');
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a unit test to verify that if it is called with a token that matches nothing, and then called with a token that does match, that unsubscribe is still successful? (Basically the 'should unsubscribe from the block tracker when called with a valid polling that was the only active pollingToken for a given networkClient' case, but with a call to the token that doesn't match

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one suggestions

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

Successfully merging this pull request may close these issues.

3 participants