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

Fix the example with Firefox on macOS when managed storage isn't available. #554

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Dalzhim
Copy link

@Dalzhim Dalzhim commented Feb 9, 2024

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.

Copy link

github-actions bot commented Feb 9, 2024

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.

@github-actions github-actions bot added the idle Issues and pull requests with no activity for three months. label Mar 11, 2024
@rebloor
Copy link
Collaborator

rebloor commented Oct 23, 2024

@Dalzhim could you provide some more information on why you think this changing necessary, managed storage has been available in Firefox from version 57

@Dalzhim
Copy link
Author

Dalzhim commented Oct 23, 2024

@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.

@github-actions github-actions bot removed the idle Issues and pull requests with no activity for three months. label Oct 23, 2024
@rebloor
Copy link
Collaborator

rebloor commented Oct 27, 2024

@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.

@rebloor rebloor closed this Oct 27, 2024
@Dalzhim
Copy link
Author

Dalzhim commented Oct 27, 2024

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.

@Rob--W
Copy link
Member

Rob--W commented Oct 28, 2024

@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 storage.managed_schema key is used instead.

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:

@rebloor
Copy link
Collaborator

rebloor commented Oct 29, 2024

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.

@rebloor rebloor reopened this Oct 29, 2024
@rebloor
Copy link
Collaborator

rebloor commented Nov 1, 2024

@dotproto any thoughts on why the lint check is failing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants