New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 813160 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Sep 25
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

gapi.auth2.init({ ... }).then(... sometimes doesn't resolve when Chrome DevTools are open

Reported by delpha...@gmail.com, Feb 16 2018

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36

Steps to reproduce the problem:
1. Open dev tools
2. Attempt to init an auth2 instance using gapi JS client
3. Sometimes observe it fail to resolve. In this case, you can wait hours and nothing will happen. However! Closing the dev tools will resolve it immediately, freeing up the page to continue.

What is the expected behavior?
Dev tools should never affect code running in the browser unless you're doing something explicit (pausing on a breakpoint, perf testing, etc)

What went wrong?
Google thenable (Google Promise) fails to resolve or reject.

Did this work before? Yes 63

Chrome version: 64.0.3282.140  Channel: n/a
OS Version: OS X 10.13.3
Flash Version: 

I almost couldn't believe it when I figured it out, but starting a few days ago I noticed that many attempts to initialize the oauth2 would simply hang-- no error nor success callback. It was particularly confusing because it was only happening on my system.

Later on, a co-worker mentioned that he saw this issue a few weeks back on Chrome Canary. His solution? Close DevTools. So sure enough, I checked in on a hung tab that had been open be on a page where the response was hanging for more then an hour. I clicked that taunting little "X" in devtools, and sure enough the promise resolved immediately.

I want to emphasize that there was no breakpoint set, and the JS thread was not paused in any way.

Related Github issue: https://github.com/google/google-api-javascript-client/issues/392
 
Cc: bsittler@chromium.org
Thanks for the report! Do you have an example page or example HTML with which the behavior can be reproduced?

Comment 3 by delpha...@gmail.com, Feb 16 2018

I do, but I'd prefer not to share it widely. Can I e-mail you directly?
Don't worry about it - I was hoping to find minimal reproduction steps to share with other Chromium contributors (approximately "the public"), so I'll keep trying to get a local instance to act this way.
Labels: Needs-Feedback
This may be a bug in GAPI rather than DevTools - it looks like gapi.auth.init's .then(...) resolves to a GoogleAuth object which has a self-resolving .then(...) causing a promise resolution loop.

As a workaround you can set an undefined 'then' own-property before using the object with promises:

Navigate to https://oauth.googleusercontent.com/robots.txt and open the JS console. Paste this into it and execute:

```js

const client_id = '359269480423-chvhi5jr4a5379f4id4cta0sd1gueqg2.apps.googleusercontent.com';

await new Promise(api_ready => document.head.append(Object.assign(document.createElement('script'), {src: 'https://apis.google.com/js/api.js', onload: api_ready})));

await new Promise(auth2_ready => gapi.load('auth2', auth2_ready));

const googleAuth = await new Promise(init_done => gapi.auth2.init({client_id: client_id, scope: 'openid'}).then(googleAuthWithThen => init_done(Object.assign(googleAuthWithThen, {then: undefined}))));

console.log('googleAuth =', googleAuth);

```

Does this resolve the issue for you?

Question for DevTools folks: is there a recent DevTools change that might cause auto-resolution of thenables (without infinite-recursion detection) where this was not previously occurring?
(The dangerous API surface is also mentioned in https://developers.google.com/identity/sign-in/web/reference#googleauththenoninit-onerror but I wouldn't expect a generic implementation of thenable-following to be able to avoid the loop.)
Labels: Needs-Triage-M64

Comment 9 by alph@chromium.org, Mar 3 2018

Components: -Platform>DevTools UI>ProximityAuth
Owner: kozy@chromium.org
Status: Assigned (was: Unconfirmed)
Alexey can help debugging why DevTools affects the promise resolution.

Comment 10 by alph@chromium.org, Mar 3 2018

Components: -UI>ProximityAuth Platform>DevTools>JavaScript
Status: WontFix (was: Assigned)
Our promise instrumentation was completely rewritten since M64. Please left a comment if this issue is still reproducible.

Sign in to add a comment