Skip reporting of successive persistence failures (#10099)

Failure to persist state will now only report to Sentry if the last
attempt to save state succeeded. This ensures that if anyone is stuck
in a state where state can't be saved (e.g. low disk space), we aren't
flooded with repeated errors on Sentry.
feature/default_network_editable
Mark Stacey 4 years ago committed by GitHub
parent bba2b9646d
commit d2b6376c3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/scripts/background.js

@ -268,6 +268,8 @@ function setupController(initState, initLangCode) {
return versionedData return versionedData
} }
let dataPersistenceFailing = false
async function persistData(state) { async function persistData(state) {
if (!state) { if (!state) {
throw new Error('MetaMask - updated state is missing') throw new Error('MetaMask - updated state is missing')
@ -278,9 +280,15 @@ function setupController(initState, initLangCode) {
if (localStore.isSupported) { if (localStore.isSupported) {
try { try {
await localStore.set(state) await localStore.set(state)
if (dataPersistenceFailing) {
dataPersistenceFailing = false
}
} catch (err) { } catch (err) {
// log error so we dont break the pipeline // log error so we dont break the pipeline
if (!dataPersistenceFailing) {
dataPersistenceFailing = true
captureException(err) captureException(err)
}
log.error('error setting state in local store:', err) log.error('error setting state in local store:', err)
} }
} }

Loading…
Cancel
Save