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

Incorrect redirection leading to not found js #156

Closed
antoniandre opened this issue Dec 18, 2018 · 47 comments
Closed

Incorrect redirection leading to not found js #156

antoniandre opened this issue Dec 18, 2018 · 47 comments

Comments

@antoniandre
Copy link

Hi,

I am getting this issue lately and it did not happen before on my 3 packages,

Accessing the package from this url does not seem to find the package I defined in my package.json > "unpkg" value.

Let's take splitpanes for instance: hitting https://unpkg.com/splitpanes redirects to the latest available package splitpanes@1.6.0, ok.
Then does not find the file set in package.json ("unpkg": "dist/splitpanes.umd.min.js") and defaults to index.js that does not exists.

Yet, if I hit https://unpkg.com/splitpanes@1.6.0/dist/splitpanes.umd.min.js directly, the file is found.

screen shot 2018-12-18 at 19 06 03

screen shot 2018-12-18 at 19 06 30

screen shot 2018-12-18 at 19 06 45

screen shot 2018-12-18 at 19 24 22

I have compared with the vue package and it works there while I have the same architecture.

Am I missing something?
Thanks for help!

@RobinCK
Copy link

RobinCK commented Dec 18, 2018

Similar problem https://unpkg.com/vue-popperjs

@smellyshovel
Copy link

smellyshovel commented Dec 18, 2018

The same for my https://unpkg.com/vue-custom-context-menu though corresponding part of the package.json is set properly

@balazsbajorics
Copy link

balazsbajorics commented Dec 18, 2018

I have stumbled on the same problem, it seems like the auto resolve that reads package.json is somehow broken

@jukben
Copy link

jukben commented Dec 18, 2018

Yeah, I've observed the same. The issue is somewhere here because it fallback to https://github.com/unpkg/unpkg.com/blob/19b2e5574b5ab5cb711ddbf27c5300d114bed4dc/modules/middleware/fetchPackage.js#L88 But I can't see it on the first sight 😞

@davidmsibley
Copy link

davidmsibley commented Dec 18, 2018

It seems like unpkg has stopped honoring module and browser properties in package.json

Currently cache MISSes of base package urls evaluate to /index.js
Weirdly enough, we still see some properly cached redirects sitting around from before this behavior.

Edit: Here's the har of two calls illustrating the cache behavior I mentioned: https://gist.github.com/davidmsibley/0e6091aae51aa347c68f10a2f957991f
The first call is a cache MISS for an older version of the package, it responds with the /index.js, and the second call is a cache HIT for the latest version of the package, resolving the correct path of the .mjs file. It's not shown here, but calling the first url again results in a cache HIT, redirecting to /index.js

@davidmsibley
Copy link

I haven't traced the line of execution back, but if @jukben is on the right track, it could have something to do with the commit that cleans the package info to cut down on memory usage for the LRU Cache

jgravois added a commit to jgravois/npmcdn that referenced this issue Dec 18, 2018
attempt to resolve mjackson#156 

disclaimer: 🚒 this patch is 100% untested! 🚒
@jgravois
Copy link
Contributor

jgravois commented Dec 18, 2018

@davidmsibley's hunch seems reasonable to me. i've proposed an (untested) patch in #157.

TIL: pkg.browser hasn't been used for awhile.

@davidmsibley
Copy link

davidmsibley commented Dec 18, 2018

@jgravois thanks for working on that!
I think that PR will do the trick. The packageConfig that's passed into filenameRedirect is from the cleaned packageConfig

@antoniandre
Copy link
Author

antoniandre commented Dec 19, 2018

Until the PR is merged and everything is fixed - hopefully - I bypass the problem (on all my codepen documentation examples) by using the tag @latest followed by direct link of the js file so that I won't need to keep updating the link when I do a new release.

This is how it looks like:
https://unpkg.com/splitpanes@latest/dist/splitpanes.umd.min.js

With this form of link the redirection to latest package file works (redirects to https://unpkg.com/splitpanes@1.7.0/dist/splitpanes.umd.min.js)

@bruceCzK
Copy link

Still has problem for https://unpkg.com/http-vue-loader

@AKPWebDesign
Copy link

I just wanted to chime in and say that every single one of the packages linked to here seems to be working fine for me. This may be fixed already, and just be CloudFlare caching the broken state. Conversely, this could still be broken, and CloudFlare is somehow caching the non-broken state at the edge location nearest to me.

Example cURL: https://gist.github.com/AKPWebDesign/f34c8377fabf145d5c2b91e55560157a

@danopia
Copy link

danopia commented Dec 20, 2018

I just clicked that most recent URL, https://unpkg.com/http-vue-loader, and it is 404ing - also with curl

But the curl for https://unpkg.com/splitpanes does in fact work for me.

Requesting from Los Angeles. I used https://unpkg.com/vue for a semi-production app. :(

@dead-claudia
Copy link

dead-claudia commented Dec 20, 2018

For unpkg.com/mithril, it's returning the wrong file and causing exceptions since mithril/index.js does exist (it's just not our "main").

@antoniandre
Copy link
Author

antoniandre commented Dec 20, 2018

I just clicked that most recent URL, https://unpkg.com/http-vue-loader, and it is 404ing - also with curl

But the curl for https://unpkg.com/splitpanes does in fact work for me.

Requesting from Los Angeles. I used https://unpkg.com/vue for a semi-production app. :(

@danopia, Interestingly it still doesn't work from Australia, does https://unpkg.com/splitpanes resolves to the js file in @1.7.0?
I don't understand how it can work in some countries and not others if it's the same code, Also if it's pointing to the version 1.7.0 it means it's not cached how can it not work here then. 🤔

@dead-claudia
Copy link

@antoniandre Try it in a new private/incognito window, so you don't have the browser cache as a variable.

@xavierfoucrier
Copy link

Hi @mjackson!

I am living in France and I have a problem getting this file: https://unpkg.com/preload-it, always returning Cannot find "/index.js" in preload-it@1.2.2. I have tried with mobile 4G and many other browsers without cache enabled... always the same result.

Thx for your feedback 😉

@porsager
Copy link

@mjackson if it's cloudflare still caching, can't you force a purge cache with them?

@jgravois
Copy link
Contributor

I'm still seeing 404s (attempting to load the non-existent /index.js) in Southern California.

https://unpkg.com/@esri/arcgis-rest-request
https://unpkg.com/@esri/arcgis-rest-auth
https://unpkg.com/@esri/arcgis-rest-feature-service

@xavierfoucrier
Copy link

Problem solved for me in France! 🎉

@Sphinxxxx
Copy link

Still 404s here..

@mjackson
Copy link
Owner

mjackson commented Jan 2, 2019

@jhildenbiddle All those URLs should work now. I manually cleared the cache for them.

@xavierfoucrier Just cleared the cache for preload-it as well, so it should work now.

@jgravois Just cleared the cache for all those URLs as well. They all work for me now.

@Sphinxxxx I cleared those URLs one more time from the cache. They all work for me.

Looking into a more permanent solution for this that hopefully won't require clearing the entire cache, which would put a huge load on the origin servers.

@mjackson mjackson reopened this Jan 2, 2019
@mjackson
Copy link
Owner

mjackson commented Jan 2, 2019

Also, as a reminder to everyone this issue is only affecting redirects on bare URLs (i.e. URLs w/out a file path) on some packages for now. If you use full URL paths you shouldn't have any issue.

@mjackson
Copy link
Owner

mjackson commented Jan 2, 2019

OK, I just cleared all responses tagged with index-redirect from the CloudFlare cache. This includes all URLs that had fully-resolved version numbers in them, but no file path. This also should fix URLs that used some form of semver or npm tag (also without a file path), because those URLs just redirect to URLs with the absolute version in them.

@lbogdan
Copy link

lbogdan commented Jan 2, 2019

I can confirm it's fixed here. 👍

@Sphinxxxx
Copy link

Looks good! All links I had trouble with work again.

@jgravois
Copy link
Contributor

jgravois commented Jan 2, 2019

thanks @mjackson 🙏.

a user did report an error in an entirely different library that i am (still) able to reproduce.

https://unpkg.com/esri-leaflet-cluster

Request URL: https://unpkg.com/esri-leaflet-cluster
Request Method: GET
Status Code: 302 
Remote Address: 104.16.124.175:443
Referrer Policy: no-referrer-when-downgrade
access-control-allow-origin: *
cache-control: public, max-age=60
cf-cache-status: HIT
cf-ray: 49304c1ccb1198cb-LAX
content-length: 98
content-type: text/html; charset=utf-8
date: Wed, 02 Jan 2019 21:25:16 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
location: /esri-leaflet-cluster@2.0.0
server: cloudflare
status: 302
strict-transport-security: max-age=31536000; includeSubDomains; preload
vary: Accept, Accept-Encoding
via: 1.1 vegur
x-content-type-options: nosniff

happy to provide more information if anything else would be useful.

@porsager
Copy link

porsager commented Jan 2, 2019

I still have issues with https://unpkg.com/mithril (requests from denmark) :(

@Sphinxxxx
Copy link

If it helps to narrow things down: Both of those (esri-leaflet-cluster and mithril) work fine from Norway.

@jgravois
Copy link
Contributor

jgravois commented Jan 2, 2019

and here's an example of another lib of mine that specifies a UMD as the pkg.main, where unpkg.com incorrectly serves up the ES Module which is present at /index.js

"main": "dist/arcgis-to-geojson.js",

https://unpkg.com/@esri/arcgis-to-geojson-utils

screenshot 2019-01-02 15 21 15

(in Southern California anyway).

@mjackson
Copy link
Owner

mjackson commented Jan 3, 2019

@jgravois Just cleared the cache for both of those.

@porsager Just cleared the cache for mithril.

FWIW, these problems should go away for URLs w/out a version number as soon as the next version is published, because the latest tag will point somewhere else.

@porsager
Copy link

porsager commented Jan 3, 2019

Awesome! Thanks @mjackson - working here now!

@karanisverma
Copy link

facing same issue with
https://unpkg.com/@zoomcarindia/zcui-wc-search-widget (india)

@karanisverma
Copy link

facing same issue with
https://unpkg.com/@zoomcarindia/zcui-wc-search-widget (india)

it's working now 😂

@jhildenbiddle
Copy link

Thanks @mjackson. Very much appreciated.

(Hope this didn't ruin your holidays!)

@rogeru
Copy link

rogeru commented Jan 10, 2019

Same issue for https://unpkg.com/circuit-sdk from some location.

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

Successfully merging a pull request may close this issue.