Skip to content

Commit

Permalink
fix issues 2100 (#3081)
Browse files Browse the repository at this point in the history
* fix issues 2100

       /**
	 * fix bug: #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.
	 */

* remove comment

* Use Logger

Co-authored-by: sethkfman <[email protected]>
Co-authored-by: Ricky Miller <[email protected]>
  • Loading branch information
3 people authored Sep 1, 2021
1 parent 30814ec commit 67763b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const persistConfig = {
storage: MigratedStorage,
stateReconciler: autoMergeLevel2, // see "Merge Process" section for details.
migrate: createMigrate(migrations, { debug: false }),
timeout: 30000,
writeFailHandler: error => Logger.error(error, { message: 'Error persisting data' }) // Log error if saving state fails
};

Expand Down
3 changes: 2 additions & 1 deletion app/util/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from '../confirm-tx';

import humanizeDuration from 'humanize-duration';
import Logger from '../../util/Logger';

const { SAI_ADDRESS } = AppConstants;

Expand Down Expand Up @@ -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 };
Expand Down

0 comments on commit 67763b2

Please sign in to comment.