cdnjs / api-server

📡 API server for api.cdnjs.com - The #1 free and open source CDN built to make life easier for developers.
https://api.cdnjs.com
MIT License
89 stars 38 forks source link

Invalid JSON data returned for highlight.js #57

Closed theit8514 closed 3 years ago

theit8514 commented 3 years ago

Help request

Problem

Highlight.js returning invalid JSON data. URL: https://api.cdnjs.com/libraries/highlight.js Error: SyntaxError: JSON.parse: unterminated string at line 1 column 2626990 of the JSON data

What I have tried

Tried using CURL to fetch with cache control set to no-cache and still returns the same invalid JSON. curl -H 'Cache-Control: no-cache' https://api.cdnjs.com/libraries/highlight.js --trace-asci output.txt output.txt

MattIPv4 commented 3 years ago

👋 I just ran curl -H 'Cache-Control: no-cache' https://api.cdnjs.com/libraries/highlight.js | jq locally (piping into jq to validate the JSON), and this is returning completely valid JSON for me.

If you could provide a full response headers dump for the invalid response, that'd be great!

theit8514 commented 3 years ago
HTTP/2 200 
date: Tue, 17 Aug 2021 20:30:12 GMT
content-type: application/json; charset=utf-8
access-control-allow-credentials: true
access-control-allow-origin: *
cache-control: public, max-age=21600
etag: W/"3b7577-5/xK/ndRckL3O36agHf8NLOno4g"
expires: Wed, 18 Aug 2021 01:48:59 GMT
vary: Accept-Encoding
cf-cache-status: HIT
age: 2473
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=BnkHyZ%2Fvn0Ly2OB5ZhvRu4F2w25Xt0TOZWz8WFWGHYQaMcupKgwDY3%2BWf9VWdSTiYJlwGD9vgJndop%2FM%2FcxJamR5QPSLmNzvr%2FKVN1pgqymV729%2FoLSWk21umPQPpOk%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
server: cloudflare
cf-ray: 6805a8b26c49f1c2-ATL
MattIPv4 commented 3 years ago

Thanks -- the team are looking into it!

MattIPv4 commented 3 years ago

Hi @theit8514,

It looks like for some reason a bad response was in a cache somewhere -- we've purged the cache, so hopefully, all should be good now! Could you check and confirm?

We've verified the responses from the API origin servers directly, as well as through the public API URL above and we can no longer reproduce the issue on our end.

theit8514 commented 3 years ago

Yes, that has fixed the issue for me as well. Thanks.