mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
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.
This commit is contained in:
parent
bba2b9646d
commit
d2b6376c3d
@ -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
|
||||||
captureException(err)
|
if (!dataPersistenceFailing) {
|
||||||
|
dataPersistenceFailing = true
|
||||||
|
captureException(err)
|
||||||
|
}
|
||||||
log.error('error setting state in local store:', err)
|
log.error('error setting state in local store:', err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user