Skip to content

Only draw chart on crates page once Google Charts has been loaded. #1740

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

Merged
merged 1 commit into from
May 8, 2019

Conversation

smarnach
Copy link
Contributor

@smarnach smarnach commented May 7, 2019

The acceptance tests are failing for me when running them locally. Some tests error out with an error like this

not ok 122 Chrome 74.0 - [undefined ms] - Global error: Uncaught TypeError: window.google.visualization.arrayToDataTable is not a function at http://localhost:7357/assets/cargo.js, line 682
 While executing test: Acceptance | crate page: /crates/:crate is accessible
    ---
        browser log: |
            testContext: [object Object]
            ERROR: Uncaught TypeError: window.google.visualization.arrayToDataTable is not a function at http://localhost:7357/assets/cargo.js, line 682
            
    ...

while other tests time out (with a ridiculously long timeout of like three minutes per test). I get similar errors in the JavaScript console when loading the live version of crates.io in Chrome 74, though the page renders just fine.

Looking at the code, the errors are expected. The didRender() hook is triggered by the initial rendering of the corresponding element, regardless of whether the Google Charts library has already been completely loaded. I seem to be on a slower internet connection than most other people running these tests, so for me the Google Charts library is usually not loaded at that point. However, the current code goes ahead with calls to the library even if it isn't loaded. This trivial fix simply exits early if the lib isn't loaded yet, because in that case there is no point in doing any further work. This fixed the acceptance tests for me, and also gets rid of the logged error in the Chrome JS console when loading the page.

@smarnach
Copy link
Contributor Author

smarnach commented May 8, 2019

@jtgeibel
Copy link
Member

jtgeibel commented May 8, 2019

Thanks @smarnach. I wasn't able to replicate the issue locally, but I agree this aligns with the previous behavior.

@bors r+

@bors
Copy link
Contributor

bors commented May 8, 2019

📌 Commit 16123af has been approved by jtgeibel

bors added a commit that referenced this pull request May 8, 2019
Only draw chart on crates page once Google Charts has been loaded.

The acceptance tests are failing for me when running them locally. Some tests error out with an error like this
```
not ok 122 Chrome 74.0 - [undefined ms] - Global error: Uncaught TypeError: window.google.visualization.arrayToDataTable is not a function at http://localhost:7357/assets/cargo.js, line 682
 While executing test: Acceptance | crate page: /crates/:crate is accessible
    ---
        browser log: |
            testContext: [object Object]
            ERROR: Uncaught TypeError: window.google.visualization.arrayToDataTable is not a function at http://localhost:7357/assets/cargo.js, line 682

    ...
```
while other tests time out (with a ridiculously long timeout of like three minutes per test). I get similar errors in the JavaScript console when loading the live version of crates.io in Chrome 74, though the page renders just fine.

Looking at the code, the errors are expected. The `didRender()` hook is triggered by the initial rendering of the corresponding element, regardless of whether the Google Charts library has already been completely loaded. I seem to be on a slower internet connection than most other people running these tests, so for me the Google Charts library is usually not loaded at that point. However, the current code goes ahead with calls to the library even if it isn't loaded. This trivial fix simply exits early if the lib isn't loaded yet, because in that case there is no point in doing any further work. This fixed the acceptance tests for me, and also gets rid of the logged error in the Chrome JS console when loading the page.
@bors
Copy link
Contributor

bors commented May 8, 2019

⌛ Testing commit 16123af with merge 9c3a376...

@bors
Copy link
Contributor

bors commented May 8, 2019

☀️ Test successful - checks-travis
Approved by: jtgeibel
Pushing 9c3a376 to master...

@bors bors merged commit 16123af into rust-lang:master May 8, 2019
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.

3 participants