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

AMP Shadow with amp-access #10799

Closed
justforfun opened this issue Aug 4, 2017 · 10 comments
Closed

AMP Shadow with amp-access #10799

justforfun opened this issue Aug 4, 2017 · 10 comments

Comments

@justforfun
Copy link

When using amp-access in a PWA (Polymer), authorization and pingback are failing
The AMP content is injected in the PWA via amp shadow

On the browser console the following errors appear:

Authorization failed: : Cannot read property 'trim' of undefined​​​

Uncaught (in promise) TypeError: Pingback failed: : Cannot read property 'trim' of undefined​​​
at na (mode.js:56)
at rd (url-parse-query-string.js:31)
at Yj.f.getCorsUrl (url.js:465)
at ak (xhr-impl.js:156)
at Yj.f.sendSignal (xhr-impl.js:288)
at amp-access-client.js:143
at

You can reproduce the issue here:
https://pwa-news.appspot.com/article/chrome/trenta-gradi-e-non-e-finita-il-comune-scatta-l-allerta-1.15504847

schermata 2017-08-04 alle 16 57 19

@aghassemi
Copy link
Contributor

/to @cvializ

@cvializ
Copy link
Contributor

cvializ commented Aug 10, 2017

Not sure immediately what the issue is, but after some time I notice that somehow pingback requests do get sent, and the response gives a CORS error. The authorization and pingback endpoints will need the CORS headers added before they will work.
screen shot 2017-08-10 at 4 19 10 pm

@justforfun
Copy link
Author

justforfun commented Aug 11, 2017 via email

@justforfun
Copy link
Author

Now the CORS error isn't present anymore. We are observing the authorization request triggered and a correct response coming back from the authorization endpoint.

Authorization Request:
https://api.gelocal.it/checkpw-v1/messaggeroveneto/amp/authorization?rid=amp-hMtvRseUWBGXJRb3v9bsUg&pubtime=2017-05-09T11:36:22Z&ts=1502460010161&url=http%3A%2F%2Fmessaggeroveneto.gelocal.it%2Fudine%2Fcronaca%2F2017%2F06%2F18%2Fnews%2Ftrenta-gradi-e-non-e-finita-il-comune-scatta-l-allerta-1.15504847&__amp_source_origin=https%3A%2F%2Fpwa-news.appspot.com

Authorization Response:
{"showContent":true,"premiumContent":true,"pw2":false,"logged":false,"freeview":true,"read":3,"remaining":2,"barrier":5,"pwProfile":{"id":2255,"position":280,"name":"finegil-member-5","desc":"Contenuto che richiede registrazione dopo 5 accessi"}}

Nevertheless, on the console it appears an error message related to the authorization method:
schermata 2017-08-11 alle 16 26 59

As for the pingback method it always fails with the following error trapped:
Uncaught (in promise) TypeError: Pingback failed: : Cannot read property 'trim' of undefined​​​
at na (shadow-v0.js:1)
at pd (shadow-v0.js:59)
at Wj.f.getCorsUrl (shadow-v0.js:385)
at Yj (shadow-v0.js:382)
at Wj.f.sendSignal (shadow-v0.js:385)
at amp-access-client.js:143
at

schermata 2017-08-11 alle 16 29 35

@rudygalfi
Copy link
Contributor

cc @dvoytenko

@aghassemi
Copy link
Contributor

3

@cvializ
Copy link
Contributor

cvializ commented Aug 25, 2017

Hello again! We have found the root cause of this bug and we have a workaround.

The bug is caused because there is a variable name collision on the global object between the Google Analytics minified javascript file and the AMP shadow-v0 minified javascript file.

Unfortunately the workaround for this is to disable the Google Analytics javascript at the top level of PWA pages with AMP shadow content. As I understand it, you can continue using Google Analytics inside your AMP documents and collect data that way instead. Alternatively, since this collision seems to only affect the pingback feature, you might try using an alternative to that if another solution could fit your use-case.

We have a fix we think should work and you can expect a fix in production within the next 10-14 days. Thanks again for your patience while we continue addressing this bug.

@justforfun
Copy link
Author

@cvializ: Thank you! We are going to test the suggested workaround and let you know

@justforfun
Copy link
Author

I disabled Google Analytics in the PWA and now the authorization and pingback processes work properly. You can test it here:
https://pwa-news.appspot.com/article/chrome/senegalesi-in-festa-vogliamo-contare-nel-vostro-paese-1.15722298

@dvoytenko
Copy link
Contributor

@cvializ @justforfun just to stress: the collision affected way more than just pingback. We are fixing it asap, but please keep this in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants