Skip to content

Commit

Permalink
fix storage logger for storage initialization errors
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhengshs committed Nov 13, 2024
1 parent 7459b12 commit c4d3d55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/core/polyfills/URL/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/core/src/storage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');

Check failure on line 23 in packages/core/src/storage/utils.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/core

Replace `'localStorage·access·failed.·InMemoryStorage·is·used·as·a·fallback.'` with `⏎↹↹↹'localStorage·access·failed.·InMemoryStorage·is·used·as·a·fallback.',⏎↹↹`
}

// Return in-memory storage as a fallback if localStorage is not accessible
Expand All @@ -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();
}
Expand Down

0 comments on commit c4d3d55

Please sign in to comment.