MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
12.07k stars 4.93k forks source link

Remove MetaSwap Liveliness Polling #10032

Open darkwing opened 3 years ago

darkwing commented 3 years ago

Per: https://www.notion.so/airswap/Reduce-featureFlag-load-0fd49db2f87641cda7600c33b3eae9af

The /featureFlag endpoint of MetaSwap is bogging down MetaSwap's logging due the 10 minute polling done here:

https://github.com/MetaMask/metamask-extension/blob/develop/app/scripts/controllers/swaps.js#L635-L723

The MetaSwap team has asked us to remove this polling. Since we check the feature flag via fetchSwapsFeatureLiveness() at the time we request a quote, this polling appears to be unnecessary. This code does give us online/offline event support, so maybe we can more efficiently get liveliness data.

darkwing commented 3 years ago

Recommendation from @danjm:

I'd recommend removing the polling and just adding a request whenever the UI loads (in one of those start up functions in ui/index.js (you'll note there is a direct call to update the store in there

darkwing commented 3 years ago

I'm a bit concerned about adding this to ui/index.js; a majority of users won't use swaps each time, so holding up the UI to make this request (or not even awaiting it) won't prevent all that many requests.

Gal's notion request is to move the check down into the UI, which I like -- that means we only make the request when we need it, and we're already doing a liveness check, with cache, there now (https://github.com/MetaMask/metamask-extension/blob/develop/ui/app/ducks/swaps/swaps.js#L376).

We especially need to be mindful of snaps, since we wouldn't want to hold up the UI in the case the user wasn't using Ethereum mainnet.