GoogleChromeLabs / bubblewrap

Bubblewrap is a Command Line Interface (CLI) that helps developers to create a Project for an Android application that launches an existing Progressive Web App (PWAs) using a Trusted Web Activity.
Apache License 2.0
2.38k stars 162 forks source link

Unexpected token error [PWABuilder] #703

Closed amrutha95 closed 2 years ago

amrutha95 commented 2 years ago

Describe the bug

The issue was raised on the PWABuilder repo. We use bubblewrap to package TWAs. Version 1.17.0

This is the error: Error: Error generating Android package. Status code: 500 Error: Internal Server Error Details: Error generating app package: Failed to download Web Manifest https://roocket.ir/manifest.json.Responded with status 503 stack: Error: Failed to download Web Manifest https://roocket.ir/manifest.json.Responded with status 503 at TwaGenerator.writeWebManifest (/app/node_modules/@bubblewrap/core/dist/lib/TwaGenerator.js:221:19) at processTicksAndRejections (internal/process/task_queues.js:97:5) at TwaGenerator.createTwaProject (/app/node_modules/@bubblewrap/core/dist/lib/TwaGenerator.js:350:13) at BubbleWrapper.generateTwaProject (/app/build/bubbleWrapper.ts:112:9) at BubbleWrapper.generateAppPackage (/app/build/bubbleWrapper.ts:53:9) at createAppPackageWith403Fallback (/app/routes/project.ts:249:12) at createAppPackage (/app/routes/project.ts:225:12) at /app/routes/project.ts:36:24

image

To Reproduce Steps to reproduce the behavior: bubblewrap init --manifest=https://roocket.ir/manifest.json

Expected behavior

andreban commented 2 years ago

@amrutha95 can you provide steps taken to check the issue before filing so we avoid repeating debugging?

In general, I'd recommend running curl -v <manifest url> before bringing the issue over from PWA Builder:

Running curl -v https://roocket.ir/manifest.json shows the URL returns an HTML instead of a JSON, when not loaded from the browser :

Expand for the results

``` * Trying 104.21.233.137:443... * Connected to roocket.ir (104.21.233.137) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/cert.pem * CApath: none * (304) (OUT), TLS handshake, Client hello (1): * (304) (IN), TLS handshake, Server hello (2): * (304) (IN), TLS handshake, Unknown (8): * (304) (IN), TLS handshake, Certificate (11): * (304) (IN), TLS handshake, CERT verify (15): * (304) (IN), TLS handshake, Finished (20): * (304) (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=*.roocket.ir * start date: Apr 10 11:01:09 2022 GMT * expire date: Jul 9 11:01:08 2022 GMT * subjectAltName: host "roocket.ir" matched cert's "roocket.ir" * issuer: C=US; O=Let's Encrypt; CN=E1 * SSL certificate verify ok. * Using HTTP2, server supports multiplexing * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x7f93ae011400) > GET /manifest.json HTTP/2 > Host: roocket.ir > user-agent: curl/7.79.1 > accept: */* > * Connection state changed (MAX_CONCURRENT_STREAMS == 256)! < HTTP/2 403 < date: Tue, 07 Jun 2022 09:54:01 GMT < content-type: text/html; charset=UTF-8 < cf-chl-bypass: 1 < permissions-policy: accelerometer=(),autoplay=(),camera=(),clipboard-read=(),clipboard-write=(),fullscreen=(),geolocation=(),gyroscope=(),hid=(),interest-cohort=(),magnetometer=(),microphone=(),payment=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),sync-xhr=(),usb=() < cache-control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0 < expires: Thu, 01 Jan 1970 00:00:01 GMT < x-frame-options: SAMEORIGIN < expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" < report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=D2yQGiu8DTRUt%2B%2Barg4I1A1HDk16gM%2FfpQldpy8QB%2BACTfF%2BqLN2a9P6v32Pc2FxxHQDFQwXI3FaRpwLExtx6QnVjN1eL7qzj86%2Bvau7IJ%2Ft9PfPHU38RUGQrDpC"}],"group":"cf-nel","max_age":604800} < nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800} < strict-transport-security: max-age=15552000; includeSubDomains; preload < x-content-type-options: nosniff < server: cloudflare < cf-ray: 717881051992f43b-LHR < alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400 < Please Wait... | Cloudflare

Please wait...

We are checking your browser... roocket.ir

Please stand by, while we are checking your browser...

Why do I have to complete a CAPTCHA?

Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

What can I do to prevent this in the future?

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

table
* Connection #0 to host roocket.ir left intact ```

https://github.com/pwa-builder/PWABuilder/issues/2777, however, is about a different URL: https://tekye.net/site.webmanifest/. Running curl -v https://tekye.net/site.webmanifest shows the server returns a 500 error when the URL is loaded outside the browser:

Expand for the results ``` ❯ curl -v https://tekye.net/site.webmanifest * Trying 185.120.222.125:443... * Connected to tekye.net (185.120.222.125) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/cert.pem * CApath: none * (304) (OUT), TLS handshake, Client hello (1): * (304) (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=tekye.net * start date: May 5 18:24:33 2022 GMT * expire date: Aug 3 18:24:32 2022 GMT * subjectAltName: host "tekye.net" matched cert's "tekye.net" * issuer: C=US; O=Let's Encrypt; CN=R3 * SSL certificate verify ok. * Using HTTP2, server supports multiplexing * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x7fb1e600b600) > GET /site.webmanifest HTTP/2 > Host: tekye.net > user-agent: curl/7.79.1 > accept: */* > * Connection state changed (MAX_CONCURRENT_STREAMS == 128)! < HTTP/2 500 < server: openresty < date: Tue, 07 Jun 2022 09:59:09 GMT < content-length: 0 < cache-status: 0 < * Connection #0 to host tekye.net left intact ```

Error messages can be improved, but the underlying issue in both cases is that the remote server is not returning a valid JSON.