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
26c8cd49e0
commit
8dd8bfd690
@ -268,6 +268,8 @@ function setupController(initState, initLangCode) {
|
||||
return versionedData
|
||||
}
|
||||
|
||||
let dataPersistenceFailing = false
|
||||
|
||||
async function persistData(state) {
|
||||
if (!state) {
|
||||
throw new Error('MetaMask - updated state is missing')
|
||||
@ -278,9 +280,15 @@ function setupController(initState, initLangCode) {
|
||||
if (localStore.isSupported) {
|
||||
try {
|
||||
await localStore.set(state)
|
||||
if (dataPersistenceFailing) {
|
||||
dataPersistenceFailing = false
|
||||
}
|
||||
} catch (err) {
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user