From c4d3d55bf54db670c2706f3e8aecedce35c28f2f Mon Sep 17 00:00:00 2001 From: yuhengshs Date: Wed, 13 Nov 2024 10:38:30 -0800 Subject: [PATCH] fix storage logger for storage initialization errors --- packages/core/polyfills/URL/index.js | 1 + packages/core/src/storage/utils.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 packages/core/polyfills/URL/index.js diff --git a/packages/core/polyfills/URL/index.js b/packages/core/polyfills/URL/index.js new file mode 100644 index 00000000000..6745cf86f3f --- /dev/null +++ b/packages/core/polyfills/URL/index.js @@ -0,0 +1 @@ +(()=>{var e,r={515:e=>{"use strict";e.exports=require("react-native-url-polyfill/auto")}},o={},t={};"test"!==(null===(e=null===process||void 0===process?void 0:process.env)||void 0===e?void 0:e.NODE_ENV)&&function e(t){var s=o[t];if(void 0!==s)return s.exports;var i=o[t]={exports:{}};return r[t](i,i.exports,e),i.exports}(515);var s=exports;for(var i in t)s[i]=t[i];t.__esModule&&Object.defineProperty(s,"__esModule",{value:!0})})(); \ No newline at end of file diff --git a/packages/core/src/storage/utils.ts b/packages/core/src/storage/utils.ts index 8307f205917..dc639987c86 100644 --- a/packages/core/src/storage/utils.ts +++ b/packages/core/src/storage/utils.ts @@ -20,7 +20,7 @@ export const getLocalStorageWithFallback = (): Storage => { } } catch (e) { // Handle any errors related to localStorage access - logger.error('LocalStorage access failed:', e); + logger.info('localStorage access failed. InMemoryStorage is used as a fallback.'); } // Return in-memory storage as a fallback if localStorage is not accessible @@ -44,7 +44,9 @@ export const getSessionStorageWithFallback = (): Storage => { throw new Error('sessionStorage is not defined'); } catch (e) { // Handle any errors related to sessionStorage access - logger.error('SessionStorage access failed:', e); + logger.info( + 'sessionStorage access failed. InMemoryStorage is used as a fallback.', + ); return new InMemoryStorage(); }