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

Race condition on google-client-loader #75

Open
softkot opened this issue Jul 30, 2016 · 9 comments
Open

Race condition on google-client-loader #75

softkot opened this issue Jul 30, 2016 · 9 comments

Comments

@softkot
Copy link

softkot commented Jul 30, 2016

It looks like the code in ready hook may not works properly and event js-api-load could be fired earlier than it is listned so the client is never loaded.

  this._loader = document.createElement('google-js-api');
        this.listen(this._loader, 'js-api-load', '_loadClient');

Tested on Google Chrome 52.0.2743.82 (64-bit)

softkot added a commit to softkot/google-apis that referenced this issue Jul 30, 2016
@softkot
Copy link
Author

softkot commented Jul 30, 2016

Pull request to workaround #76

@ebidel
Copy link
Contributor

ebidel commented Jul 30, 2016

Can you post a jsbin that repos the race condition. I'd like to understand whst caused the problem instead of hacking around it.

@softkot
Copy link
Author

softkot commented Jul 31, 2016

I just create a jsbin https://jsbin.com/koquvi/9/edit?html,output but if works just fine because refer to polymer-cdn where https://github.com/Download/polymer-cdn/blob/master/lib/google-apis/google-client-loader.html use

 <template>
    <google-js-api on-js-api-load="_loadClient"></google-js-api>
  </template>

instead ready hook in latest repo. If you change it to latest https://github.com/GoogleWebComponents/google-apis/blob/master/google-client-loader.html it will fail to race conditions.

@softkot
Copy link
Author

softkot commented Jul 31, 2016

This was broken in #72

@tjmonsi
Copy link

tjmonsi commented Sep 5, 2016

Actually I am having problems on it as well, especially on slow internet speeds. The quick hack on #76 did the trick.

@dmurph
Copy link

dmurph commented Jan 27, 2017

This happens for me every time.

@mrabdallah
Copy link

I tried setting interval in ready function like this
var intervalId = setInterval(function(){ if(gapi.client){ var clients = that.querySelectorAll("google-client-loader"); for (var i = 0; i < clients.length; i++) { clients[i]._loadClient(); } clearInterval(intervalId); } else gapi.load('client', function(){}); }, 3000);
and it worked for me

@peterfortuin
Copy link

I'm using the 2.x version of this element and have the same race condition. For me it happend because I have 10 times the google-client-loader element in my dom tree with different endpoints to connect to. The fix mentioned in #76 fixed my problems.

@peterfortuin
Copy link

I have created a pull request (#99) to solve this for the 2.x branch.

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

No branches or pull requests

6 participants