As of two days ago Thenable objects seem to have stopped working for us.
Examples of usage:
window.gapi.auth2.init({
client_id: config.google.clientId,
scope: 'https://www.googleapis.com/auth/calendar',
}).then(...);
this.state.client.grantOfflineAccess(options).then(this.onLogin)
These promises simply never resolve or reject. Furthermore, the behavior seems nondeterministic. It will fail most of the time and succeed rarely. And, for some reason, it works 100% of the time in development, but is failing in staging and production.
Have there been any changes that would cause this?
https://github.com/google/google-api-javascript-client/issues/258 is reporting similar behavior.
https://github.com/google/google-api-javascript-client/issues/232 appears to also be similar.
Hi Oliver,
Thanks for reporting the issue and linking to similar bugs. I am not aware of any changes in the library that would create the issue. I tried to reproduce it without success, the initialization does return a Thenable that is resolved.
Could you provide the console stack trace, if there's any? There is maybe a different bug leading to this observation.
If no stack trace is observed, could you provide me with a minimal code snippet, with the HTML, that reproduces the issue, so I can ensure it is done right?
@TMSCH thanks for the reply!
We can't seem to repro the issue locally, so I'm afraid it won't be very helpful for you. Also, there is no console stack trace for the issue. However, the issue is present in production: you could try this URL and sign in with any google account: https://home.claralabs.com/login
Working behavior would give you an error message saying we don't have that account in our system. The breaking behavior (which happens most of the time) is when the popup goes away and nothing changes on the page.
This links works as expected (error message shown) for me on Chrome Linux, and Chrome and Safari on Max OS X. What browser/platform are you using?
@TMSCH I just checked again and it seems to be consistently working again. Before, we were seeing maybe 80/20 fail/succeed. We certainly didn't change anything on our end. Did you change anything on your end?
I suspected some kind of loading race condition, but changing my internet speed throttling still can't repro. Bizarre.
I am not aware on any change on our end that could have caused and fixed this issue, this is weird. It is possible that some backend requests failed without raising a console error, due to transient issues not related to the client SDK (such as network errors).
If this issue happens again, please report what you see in the Network tab of the developers console, especially failed requests, if any.
Hi folks, any updates on the issue?
Hi @SVLayer, are you still observing the issue? It seems that it had been fixed. If you are, please provide a code snippet that reproduces it, and any console/network logs that you observe. Thanks!
Still observing this issue with signIn()
@czzarr have you tried again recently? Was that the issue with prompt: 'none'? This now rejects the promise with an error. Could you try to see if you observe this?
@czzarr @SVLayer have you tried again? Are you still observing the issue?
Closing the issue as not reproducible. Please reopen if you are still observing the issue.
Found out that promise returned by gapi.client.init is not rejected in case of network problem. In a following example neither onFulfilled nor onRejected is called:
gapi.client.init({
discoveryDocs: ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest'],
clientId: google_app_id,
scope: 'https://www.googleapis.com/auth/drive'
}).then(
onFulfilled,
onRejected
)
Also, is there any way to detect that gapi.load fails?
To detect gapi.load failures, you can use the following:
gapi.load('client', {
callback: initClient,
timeout: 1000, // Timeout in ms, compulsory if you use the ontimeout callback.
ontimeout: onTimeoutCallback,
onerror: onErrorCallback
});
Where initClient, onTimeoutCallback and onErrorCallback are functions.
It seems that gapi.client.init does not reject on all network errors indeed. We will address this.
This is indeed a bug that gapi.client.init won't resolve when it needs to load gapi.auth2. We will work on a fix.
Tnx for a fast reply! Waiting for the fix.
On Thu, Jul 20, 2017 at 3:22 AM, Thomas Césaré-Herriau <
[email protected]> wrote:
To detect gapi.load failures, you can use the following:
gapi.load('client', {
callback: initClient,
timeout: 1000, // Timeout in ms, compulsory if you use the ontimeout callback.
ontimeout: onTimeoutCallback,
onerror: onErrorCallback
});Where initClient, onTimeoutCallback and onErrorCallback are functions.
It seems that gapi.client.init does not reject on all network errors
indeed. We will address this.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/google-api-javascript-client/issues/265#issuecomment-316560317,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFGNk1gulE7CQX95LgtWYLdtr2JmSoG3ks5sPp23gaJpZM4Le1fQ
.
--
С уважением, Ходько Петр
Any update on this? I'm running into the same of behavior. Thanks.
I have just encountered this issue as well. The init function is neither fulfilling nor breaking the promise, and just never returns. This is after loading client:auth2 as mentioned earlier. In case it is relevant, I am attempting to load the drive rest v2 discovery doc with full auth scope.
Does anybody know of a workaround while this is being addressed?
@Atlowell what browser are you using?
I am using Google Chrome @TMSCH
Could you provide a snippet of code that reproduces the issue, @Atlowell? Also, please provide console logs (if any) and any network logs for requests to the origins https://accounts.google.com and https://apis.google.com. Thanks!
@TMSCH
Console Logs:

The snippet of code that produces the first 2 items in the log. It thinks gapi.client is undefined, probably because the init function never returns.

The authorization code. The load function returns and logs that it has entered the callback function, but the init function's promise never happens, and neither "init function" nor the error are logged to the console.

Network logs for apis.google.com


Network logs for accounts.google.com

@Atlowell based on that I am not able to tell whether it's an issue with gapi. Where do you call populateTree? Where do you assign gapi to the this in populateTree?
@TMSCH At the end of the authentication script I linked earlier (which is the last script loaded) are 2 function calls. The first calls the authorization load function pictured, and the second calls another function. The second function creates a new object that I defined, and passes in gapi to the constructor, which then gets set as the objects this.gapi. populateTree() is called in that objects constructor after setting this.gapi.
Either way, the init function doesn't return. If you comment out the setupOverDrive() function and only do authentication, nothing gets logged past calling init() (the promise never fulfills either way).
@Atlowell this is still pretty confusing. setupOverDrive should not be called right after the call to clientLoadAuth. It should be called in the clientInitAuth, in the then() method's body. Otherwise client will not be defined on gapi, so the error "Cannot read property 'drive' of undefined" is expected.
Based on the network logs, it seems that auth2 is not even initialized, which is weird. Is there any IFrame with src to https://accounts.google.com/... loaded?
Hi, Thomas. Is there any way to open Google Drive share dialog in a window?
As for now, if user is not authorized, then google authorization form fails
to be be loaded in the iframe.
On Thu, Jul 20, 2017 at 3:22 AM, Thomas Césaré-Herriau <
[email protected]> wrote:
To detect gapi.load failures, you can use the following:
gapi.load('client', {
callback: initClient,
timeout: 1000, // Timeout in ms, compulsory if you use the ontimeout callback.
ontimeout: onTimeoutCallback,
onerror: onErrorCallback
});Where initClient, onTimeoutCallback and onErrorCallback are functions.
It seems that gapi.client.init does not reject on all network errors
indeed. We will address this.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/google-api-javascript-client/issues/265#issuecomment-316560317,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFGNk1gulE7CQX95LgtWYLdtr2JmSoG3ks5sPp23gaJpZM4Le1fQ
.
--
С уважением, Ходько Петр
@petrovy4 not that I'm aware of. You should probably handle the user not being authenticated before calling the API, in case you need the user to sign in.
ok, tnx
On Oct 31, 2017 17:03, "Thomas Césaré-Herriau" notifications@github.com
wrote:
@petrovy4 https://github.com/petrovy4 not that I'm aware of. You should
probably handle the user not being authenticated before calling the API, in
case you need the user to sign in.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/google/google-api-javascript-client/issues/265#issuecomment-340790810,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFGNk1n0jPIo3s9DFbOhT_MPjUVohqWyks5sxzaUgaJpZM4Le1fQ
.
Is there any movement on fixing it?
Most helpful comment
This is indeed a bug that gapi.client.init won't resolve when it needs to load gapi.auth2. We will work on a fix.