LibraryManager icon indicating copy to clipboard operation
LibraryManager copied to clipboard

Should not place unusable responses from providers into metadata cache

Open jimmylewis opened this issue 3 years ago • 1 comments

Describe the bug

See this detailed writeup

To Reproduce

Steps to reproduce the behavior:

  1. Download a library but get an invalid (unparseable) JSON response from the provider
  2. Try again, expecting the retry to return a valid JSON payload

Operation fails again, because the bad response is placed in the cache, so we keep reusing it.

Expected behavior

Should issue the request to the provider again, and get a fresh (hopefully functional) response.

jimmylewis avatar May 03 '21 15:05 jimmylewis

Just retry the request may not be enough to fix the issue. I tested a few times and found the provider's CDN will return the same broken JSON for a same IP and user agent. To force the provider to return a fresh response, libman may need to have a method to make CDN think it is not the same client.

Libman can't change client IP, so there may be two options to force CDN to refresh

  • Append a random number to the query string like: https://api.cdnjs.com/libraries/tinymce?996
  • Add a random user agent string to the request header

EdiWang avatar May 03 '21 23:05 EdiWang