Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[system] Catch localStorage unavailability #34027

Merged
merged 1 commit into from
Aug 22, 2022

Conversation

jsakas
Copy link
Contributor

@jsakas jsakas commented Aug 21, 2022

I was trying to use Joy UI to build a Figma plugin, but localStorage is not available in this environment and so the library could not be used. This would also be the case for private mode as mentioned in #33853

This PR just wraps all of the calls in a try / catch, which was how one call was already handled.

Another solution might be to create our own class, similar to a polyfill, that wraps localStorage and proxies commands with a try catch, so the code calling localStorage becomes smaller and potentially more readable.

I didn't not want to make too many assumptions about how MUI team wants to resolve the bug so let me know what you think and I will update if needed.

closes #33853

@mui-bot
Copy link

mui-bot commented Aug 21, 2022

Details of bundle changes

Generated by 🚫 dangerJS against 652b326

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siriwatknp siriwatknp added bug 🐛 Something doesn't work package: system Specific to @mui/system and removed bug 🐛 Something doesn't work labels Aug 22, 2022
@siriwatknp siriwatknp merged commit a8315e0 into mui:master Aug 22, 2022
@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work regression A bug, but worse labels Sep 23, 2022
@oliviertassinari oliviertassinari changed the title [system] catch localStorage errors [system] Catch localStorage unavailability Sep 23, 2022
@oliviertassinari oliviertassinari removed the regression A bug, but worse label Sep 23, 2022
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this pull request Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[system] CssVarsProvider should not crash the app if local storage is unavailable
4 participants