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 documentation not showing on localStorage error #81964

Merged
merged 2 commits into from
Feb 12, 2021

Conversation

lovasoa
Copy link
Contributor

@lovasoa lovasoa commented Feb 10, 2021

Fixes #81928

The documentation for setItem specifies:

developers should make sure to always catch possible exceptions from setItem()

Fixes rust-lang#81928

“Ask forgiveness not permission”  : this makes the code both simpler and more robust
@rust-highfive
Copy link
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 10, 2021
@GuillaumeGomez
Copy link
Member

I really like this simplification which allows us to handle all cases. Thanks!

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Feb 10, 2021

📌 Commit 16f0ccd has been approved by GuillaumeGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 10, 2021
try {
window.localStorage.setItem(name, value);
} catch(e) {
// localStorage is not accessible, do nothing
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it make sense to attempt to call localStorage.clear() here in case enough data accumulated to reach the per-site limit?

Copy link
Member

Choose a reason for hiding this comment

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

Why would you want to remove all your data if you can't add more?

Copy link
Member

Choose a reason for hiding this comment

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

That's assuming something filled up the storage to its limit which prevents storing new data, e.g. due to previous iterations of the site.

Copy link
Member

Choose a reason for hiding this comment

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

We store very little amount of information in the local storage (less than 40 bytes iirc), so we should be fine. ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe this can be discussed outside of the context of this pull request ?
If new behavior needs to be introduced, it can be independently of this bug fix.

Copy link
Member

Choose a reason for hiding this comment

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

No need, if there's nothing that could cause unbounded growth then the limitation is probably due to something else, e.g. a browser simply having localstorage disabled, clear() wouldn't help with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we good to merge, then ?

Copy link
Member

Choose a reason for hiding this comment

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

I already approved it so it should be merged in the next days.

JohnTitor added a commit to JohnTitor/rust that referenced this pull request Feb 11, 2021
Fix documentation not showing on localStorage error

Fixes rust-lang#81928

The [documentation for setItem](https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem) specifies:

> developers should make sure to always catch possible exceptions from setItem()
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Feb 11, 2021
Fix documentation not showing on localStorage error

Fixes rust-lang#81928

The [documentation for setItem](https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem) specifies:

> developers should make sure to always catch possible exceptions from setItem()
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 11, 2021
Fix documentation not showing on localStorage error

Fixes rust-lang#81928

The [documentation for setItem](https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem) specifies:

> developers should make sure to always catch possible exceptions from setItem()
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Feb 12, 2021
Fix documentation not showing on localStorage error

Fixes rust-lang#81928

The [documentation for setItem](https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem) specifies:

> developers should make sure to always catch possible exceptions from setItem()
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 12, 2021
Rollup of 16 pull requests

Successful merges:

 - rust-lang#79983 (fix indefinite article in cell.rs)
 - rust-lang#81831 (Don't display `mut` in arguments for functions documentation)
 - rust-lang#81947 (Relax ItemCtxt::to_ty lifetime)
 - rust-lang#81954 (RELEASES.md 1.50: Group platform support notes together)
 - rust-lang#81955 (bootstrap: Locate llvm-dwp based on llvm-config bindir)
 - rust-lang#81959 (Fix assosiated typo)
 - rust-lang#81964 (Fix documentation not showing on localStorage error)
 - rust-lang#81968 (bootstrap: fix wrong docs installation path)
 - rust-lang#81990 (Make suggestion of changing mutability of arguments broader)
 - rust-lang#81994 (Improve long explanation for E0542 and E0546)
 - rust-lang#81997 (dist: include src/build_helper as part of the crate graph for rustc-dev)
 - rust-lang#82003 (Stack probes: fix error message)
 - rust-lang#82004 (clean up clean::Static struct)
 - rust-lang#82011 (Fix private intra-doc warnings on associated items)
 - rust-lang#82013 (Tell user how to fix CI file being not up to date)
 - rust-lang#82017 (Fix typo in mod.rs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0f47e19 into rust-lang:master Feb 12, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 12, 2021
@lovasoa lovasoa deleted the patch-1 branch February 12, 2021 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc JS does not handle NO_DEVICE_SPACE error
6 participants