From 2444b966e7e4d976680da3d92bf3a6cfbeee8075 Mon Sep 17 00:00:00 2001 From: liangwu Date: Tue, 31 Aug 2021 13:31:06 +0800 Subject: [PATCH 1/3] fix issues 2100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /** * fix bug: https://github.com/MetaMask/metamask-mobile/issues/2100 * * reason: redux-persist load storage data by 'getItem' API with a timeout (5 seconds default) when app ’cold start', * on some old devices, I/O is slow and 'readfile' operation may take long time Occasionally, when this happened, timeout * will lead to redux-persist rehydrate state with undefined and an Error(https://github.com/rt2zz/redux-persist/blob/master/src/persistReducer.js#89). * * solution: the easy way to fix is to set a big timeout on config, Go further, we could save 'keyring' etc some important * data to separate files or backup for this. the second way is not complicated, we could set * serialize and deserialize to false to get JSON object and modify setItem/getItem API to save/load data. */ --- app/store/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/store/index.js b/app/store/index.js index 556b8914c66..e7855ea03db 100644 --- a/app/store/index.js +++ b/app/store/index.js @@ -50,6 +50,18 @@ const persistConfig = { storage: MigratedStorage, stateReconciler: autoMergeLevel2, // see "Merge Process" section for details. migrate: createMigrate(migrations, { debug: false }), + /** + * fix bug: https://github.com/MetaMask/metamask-mobile/issues/2100 + * + * reason: redux-persist load storage data by 'getItem' API with a timeout (5 seconds default) when app ’cold start', + * on some old devices, I/O is slow and 'readfile' operation may take long time Occasionally, when this happened, timeout + * will lead to redux-persist rehydrate state with undefined and an Error(https://github.com/rt2zz/redux-persist/blob/master/src/persistReducer.js#89). + * + * solution: the easy way to fix is to set a big timeout on config, Go further, we could save 'keyring' etc some important + * data to separate files or backup for this. the second way is not complicated, we could set + * serialize and deserialize to false to get JSON object and modify setItem/getItem API to save/load data. + */ + timeout: 30000, writeFailHandler: error => Logger.error(error, { message: 'Error persisting data' }) // Log error if saving state fails }; From ebb0e568b3bb7fe95376c134ce2d730e7cf0615a Mon Sep 17 00:00:00 2001 From: Ricky Miller Date: Wed, 1 Sep 2021 13:07:20 -0400 Subject: [PATCH 2/3] remove comment --- app/store/index.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/app/store/index.js b/app/store/index.js index e7855ea03db..a491924e856 100644 --- a/app/store/index.js +++ b/app/store/index.js @@ -50,17 +50,6 @@ const persistConfig = { storage: MigratedStorage, stateReconciler: autoMergeLevel2, // see "Merge Process" section for details. migrate: createMigrate(migrations, { debug: false }), - /** - * fix bug: https://github.com/MetaMask/metamask-mobile/issues/2100 - * - * reason: redux-persist load storage data by 'getItem' API with a timeout (5 seconds default) when app ’cold start', - * on some old devices, I/O is slow and 'readfile' operation may take long time Occasionally, when this happened, timeout - * will lead to redux-persist rehydrate state with undefined and an Error(https://github.com/rt2zz/redux-persist/blob/master/src/persistReducer.js#89). - * - * solution: the easy way to fix is to set a big timeout on config, Go further, we could save 'keyring' etc some important - * data to separate files or backup for this. the second way is not complicated, we could set - * serialize and deserialize to false to get JSON object and modify setItem/getItem API to save/load data. - */ timeout: 30000, writeFailHandler: error => Logger.error(error, { message: 'Error persisting data' }) // Log error if saving state fails }; From 168f148540d8c6b8918deb58ab68a957bc6f9571 Mon Sep 17 00:00:00 2001 From: Ricky Miller Date: Wed, 1 Sep 2021 13:15:01 -0400 Subject: [PATCH 3/3] Use Logger --- app/util/transactions/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/util/transactions/index.js b/app/util/transactions/index.js index 084cc132919..fce4885e5e9 100644 --- a/app/util/transactions/index.js +++ b/app/util/transactions/index.js @@ -31,6 +31,7 @@ import { } from '../confirm-tx'; import humanizeDuration from 'humanize-duration'; +import Logger from '../../util/Logger'; const { SAI_ADDRESS } = AppConstants; @@ -653,7 +654,7 @@ export const calculateEIP1559Times = ({ timeEstimateId = AppConstants.GAS_TIMES.RANGE; } } catch (error) { - console.log('ERROR ESTIMATING TIME', error); + Logger.log('ERROR ESTIMATING TIME', error); } return { timeEstimate, timeEstimateColor, timeEstimateId };