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

Replace setInterval for polling in TokenListcontroller #15937

Closed
NiranjanaBinoy opened this issue Sep 21, 2022 · 4 comments
Closed

Replace setInterval for polling in TokenListcontroller #15937

NiranjanaBinoy opened this issue Sep 21, 2022 · 4 comments
Assignees
Labels

Comments

@NiranjanaBinoy
Copy link
Contributor

NiranjanaBinoy commented Sep 21, 2022

Replace setInterval for polling in fetchTokenList() in TokenListcontroller in a time window of 24 hours.

@bschorchit bschorchit added the MV3 label Sep 22, 2022
@NiranjanaBinoy
Copy link
Contributor Author

The corresponding PR has to be created in the controller repo.

Since the chrome alarms have to be used only for the extension, we would have to configure them at the API level to differentiate extension using mv3 from mobile and extension using mv2.
Can we introduce a new optional state variable with true value to identify extension with mv3 and use chrome alarms in that case?

@NiranjanaBinoy
Copy link
Contributor Author

Something similar to MetaMask/core#861

@NiranjanaBinoy
Copy link
Contributor Author

Closing this ticket after a conversation with the core team. Quoting the comment below and link to the chat here

Using setTimeout might be fine for the intervals that are below 5 minutes. That's not awful.
If the service worker restarts every 5 minutes, then the 3-minute intervals will be triggered once every 2.5 minutes on average. That seems fine.
Though I would check to ensure that the update is triggered upon construction as well. If it's only after 3 minutes has elapsed, then it would become a 5 minute timer in practice.

@NiranjanaBinoy
Copy link
Contributor Author

On a closer look, we found that the fetchTokenList method, which is used to fetch the dynamic tokenList, is getting called every time the UI pop or window is opened as we are starting and stopping the polling based on the controllerConnectionChangedhere. This means every time the UI opens a recurring fetch with an interval of 24 hrs is scheduled, and it gets unscheduled or cleared when the UI closes. Upon further discussion, the decision was made that the introduction of the chrome alarm for setInterval is not necessary for tokenListcontroller as there is a fetch happening every time the UI opens, and there is cache data available with a threshold of 24 hours which is to reduce the load on the server.

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

No branches or pull requests

2 participants