-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix the example with Firefox on macOS when managed storage isn't available. #554
base: main
Are you sure you want to change the base?
Conversation
…anaged storage isn't available.
It looks like this is your first pull request. 🎉 Thank you for your contribution! One of the project maintainers will triage and assign the pull request for review. We appreciate your patience. To safeguard the health of the project, please take a moment to read our code of conduct. |
@Dalzhim could you provide some more information on why you think this changing necessary, managed storage has been available in Firefox from version 57 |
@rebloor: i used the sample code and it threw the exception. I do not remember the exact circumstances now, but i was probably attempting to use that sample code from within a web extension’s background script or injected script. Nevertheless, managed storage apparently wasn’t available in the context (firefox 122 running on macos according to my original report) and if the error had already been logged, it’d have saved me some time debugging the issue. |
@Dalzhim Without more precise details, it's difficult to comment further. If you encounter the issue again or are able to reproduce it otherwise, please raise it on the forum to help determine whether it's a bug or a usage issue. In the meantime, I'm closing this PR as there don't appear to be any similar known issues with this feature. Thanks. |
I’m telling you the sample code failed throwing an exception. I believe it was in the context of a web extension. Now if you’d rather keep the sample code the way it is, meaning without proper error handling, then suit yourself. I don’t plan on commenting any further. |
@rebloor The PR author here raised a valid point: in Firefox, storage.managed.get throws if the storage manifest has not been specified. In contrast, in Chrome the default values as specified in the This difference is currently not documented on MDN, but a report exists at https://bugzilla.mozilla.org/show_bug.cgi?id=1868153 It would be useful to catch errors and print them somewhere, but with a comment explaining why. Relevant documentation can be found at: |
Sorry, @Rob--W and @Dalzhim. I should have realised that the underlying issue would be the extension storage file, not, as reported, managed storage being absent on Firefox. @Rob--W, so presumably, we need to check for the call returning undefined that shows that the managed storage file is missing, and if the file is found, then the requested key is in the storage file. |
Co-authored-by: Simeon Vincent <[email protected]>
@dotproto any thoughts on why the lint check is failing? |
When managed storage isn't available (i.e. : using Firefox 122 on macOS), the example code throws an exception while trying to restore the value from managed storage and never proceeds to restore the value saved in storage.sync.
This change handles the exception so that the example works out of the box.