From a0e25bc4c52f093ca507aec2be4ac8a094833191 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 20 Jan 2022 12:52:54 -1000 Subject: [PATCH 1/2] Throw and do not evict storage when bad data is set to Onyx --- lib/Onyx.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Onyx.js b/lib/Onyx.js index 77bfbdf04..a404cd209 100644 --- a/lib/Onyx.js +++ b/lib/Onyx.js @@ -500,6 +500,11 @@ function remove(key) { function evictStorageAndRetry(error, onyxMethod, ...args) { logInfo(`Handled error: ${error}`); + if (Str.startsWith(error.message, 'Failed to execute \'put\' on \'IDBObjectStore\'')) { + logAlert('Attempted to set invalid data set in Onyx. Please ensure all data is serializable.'); + throw error; + } + // Find the first key that we can remove that has no subscribers in our blocklist const keyForRemoval = _.find(recentlyAccessedKeys, key => !evictionBlocklist[key]); From 793fce8f4c19f2ab1a0bf349123cf6a641d7f84a Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 20 Jan 2022 13:00:09 -1000 Subject: [PATCH 2/2] prevent accessing message on undefined error --- lib/Onyx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Onyx.js b/lib/Onyx.js index a404cd209..75a8c8bcc 100644 --- a/lib/Onyx.js +++ b/lib/Onyx.js @@ -500,7 +500,7 @@ function remove(key) { function evictStorageAndRetry(error, onyxMethod, ...args) { logInfo(`Handled error: ${error}`); - if (Str.startsWith(error.message, 'Failed to execute \'put\' on \'IDBObjectStore\'')) { + if (error && Str.startsWith(error.message, 'Failed to execute \'put\' on \'IDBObjectStore\'')) { logAlert('Attempted to set invalid data set in Onyx. Please ensure all data is serializable.'); throw error; }