react-native-onyx 3.0.76 → 3.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storage/index.js +9 -21
- package/package.json +1 -1
package/dist/storage/index.js
CHANGED
|
@@ -58,27 +58,15 @@ function degradePerformance(error) {
|
|
|
58
58
|
* Runs a piece of code and degrades performance if certain errors are thrown
|
|
59
59
|
*/
|
|
60
60
|
function tryOrDegradePerformance(fn, waitForInitialization = true) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// IndexedDB error when storage is full (https://github.com/Expensify/App/issues/29403)
|
|
71
|
-
if (error.message.includes('Internal error opening backing store for indexedDB.open')) {
|
|
72
|
-
degradePerformance(error);
|
|
73
|
-
}
|
|
74
|
-
// catch the error if DB connection can not be established/DB can not be created
|
|
75
|
-
if (error.message.includes('IDBKeyVal store could not be created')) {
|
|
76
|
-
degradePerformance(error);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
reject(error);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
61
|
+
const initialization = waitForInitialization ? initPromise : Promise.resolve();
|
|
62
|
+
return initialization
|
|
63
|
+
.then(() => fn())
|
|
64
|
+
.catch((error) => {
|
|
65
|
+
// catch the error if DB connection can not be established/DB can not be created
|
|
66
|
+
if (error instanceof Error && error.message.includes('IDBKeyVal store could not be created')) {
|
|
67
|
+
degradePerformance(error);
|
|
68
|
+
}
|
|
69
|
+
return Promise.reject(error);
|
|
82
70
|
});
|
|
83
71
|
}
|
|
84
72
|
const storage = {
|