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

[rustdoc] Fix storage usage when disabled #61462

Merged
merged 1 commit into from
Jul 12, 2019

Conversation

GuillaumeGomez
Copy link
Member

Fixes #61239.

@starblue: Can you give a try to this change please? I tried on chrome and firefox and both worked so if you're using another web browser, that might be useful. :)

r? @Manishearth

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 2, 2019
@starblue
Copy link

starblue commented Jun 3, 2019

I'm using Firefox 67.0.
I tried to build Rust, but stage 1 compilation of compiler artifacts failed, I can see that it was killed.
(I suppose that was by the OOM killer due to lack of memory, as the machine only has 8GB of which about 4GB are free. I've had similar problems before with a large svd2rust-generated crate.)
So I'll wait until the fix is in nightly and check that.

@GuillaumeGomez
Copy link
Member Author

Hum, that's not very ideal. This fix is pretty simple but it'd have been nice to have a confirmation before actually merging it in case it was useless or not solving your issue.

@starblue
Copy link

starblue commented Jun 3, 2019

I finally managed to build it with -j 1, and I can report that the issue is indeed fixed. Thanks!

@GuillaumeGomez
Copy link
Member Author

Perfect, thanks! Just waiting for someone to review now.

cc @rust-lang/rustdoc

@@ -70,7 +70,7 @@ function usableLocalStorage() {
return false;
}

return true;
return window.localStorage !== null && typeof window !== 'undefined';
Copy link
Member

Choose a reason for hiding this comment

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

What is the typeof window !== 'undefined' check for?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! I'll update the code soon.

@ollie27
Copy link
Member

ollie27 commented Jun 4, 2019

It looks like this is actually quite tricky to get right. How about borrowing the code from https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#Testing_for_availability instead?

@GuillaumeGomez
Copy link
Member Author

This code seems quite long to run (to be confirmed!). Saving its state should be enough though.

@ishitatsuyuki
Copy link
Contributor

Pro tip: when letting others test a build, you can @bors try then ask them to use https://github.com/kennytm/rustup-toolchain-install-master.

@GuillaumeGomez
Copy link
Member Author

@ollie27: The code sample you linked checks too many things for us (like if the localStorage is full, which we don't really care in our case considering how little we use it). Checking if the localStorage exists is enough normally so I'll just fix the error you noticed.

@GuillaumeGomez
Copy link
Member Author

@ishitatsuyuki Thanks for the tip!

@GuillaumeGomez
Copy link
Member Author

Updated.

@QuietMisdreavus
Copy link
Member

@ollie27: The code sample you linked checks too many things for us (like if the localStorage is full, which we don't really care in our case considering how little we use it). Checking if the localStorage exists is enough normally so I'll just fix the error you noticed.

According to the MDN page they linked, we may still get errors about localStorage being full, even with our relatively light usage of it:

One example of that is Safari, which in Private Browsing mode gives us an empty localStorage object with a quota of zero, effectively making it unusable.

Also, couldn't we move the final return line into the try block? It could even replace the current contents, since we're still accessing window.localStorage which would throw the exception.

@GuillaumeGomez
Copy link
Member Author

Interesting. I'll check on safari to see its behaviour.

@GuillaumeGomez
Copy link
Member Author

Also, couldn't we move the final return line into the try block? It could even replace the current contents, since we're still accessing window.localStorage which would throw the exception.

Excellent idea! I did it.

According to the MDN page they linked, we may still get errors about localStorage being full, even with our relatively light usage of it:
...

I tried on safari, both private and "normal" modes worked fine (I could set settings everything just fine).

@Dylan-DPC-zz
Copy link

ping from triage @Manishearth waiting for your review on this

@Manishearth
Copy link
Member

@bors r+

(note for triage: i'm helping out with rustdoc reviews, but please don't block rustdoc reviews on me)

@GuillaumeGomez
Copy link
Member Author

Nothing happened apparently? I'll close then reopen and give it another try.

@GuillaumeGomez
Copy link
Member Author

@bors: r=Manishearth

@bors
Copy link
Contributor

bors commented Jul 12, 2019

📌 Commit 4eb19d1 has been approved by Manishearth

@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 Jul 12, 2019
@bors
Copy link
Contributor

bors commented Jul 12, 2019

⌛ Testing commit 4eb19d1 with merge 71f9384...

bors added a commit that referenced this pull request Jul 12, 2019
[rustdoc] Fix storage usage when disabled

Fixes #61239.

@starblue: Can you give a try to this change please? I tried on chrome and firefox and both worked so if you're using another web browser, that might be useful. :)

r? @Manishearth
@bors
Copy link
Contributor

bors commented Jul 12, 2019

☀️ Test successful - checks-azure, checks-travis, status-appveyor
Approved by: Manishearth
Pushing 71f9384 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 12, 2019
@bors bors merged commit 4eb19d1 into rust-lang:master Jul 12, 2019
@GuillaumeGomez GuillaumeGomez deleted the fix-local-storage branch July 12, 2019 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

Rust documentation doesn't show implementations when cookies / storage are disabled
9 participants