unpkg: Incorrect redirection leading to not found js

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!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 13
  • Comments: 47 (10 by maintainers)

Commits related to this issue

Most upvoted comments

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

Sorry for the inconvenience everyone! aa99d11 was a bad deploy, which I rolled back yesterday. So everything should be back to normal now. Going to push a more permanent fix soon.

FWIW, I can confirm that the links provided @San4es and @Sphinxxxx currently load without issue in the US (NY) but fail when loaded from Norway. Testing was done using a VPN and Chrome in incognito mode to avoid caching issues.

Similarly, I have several URLs that users in Argentina and British Columbia are reporting as broken that load without issue here in the US.

Finally, I have at least one lib that fails to load from the US as well:

I’m hoping the solution is just to wait a bit longer for the caches to clear (CDN & local).


Follow Up (+1 day)

Continuing to test using https://unpkg.com/class-change. Loads fine using “US California” VPN node but fails using “US Seattle” and “US New York”.

@mjackson – Any chance we can reopen this issue until the situation is resolved? Also, any thoughts on these issues resolving themselves or if additional work needs to be done?


Follow Up (+2 days)

Continuing to test using https://unpkg.com/class-change. Still fails as described above. This is not the only library I maintain that’s affected, just one I can easily test because 1) users have brought it to my attention and 2) I can test affected locations using a VPN service.

I’m losing hope that this issue will resolve itself, so the next steps are to swap all CDN links listed for my NPM packages from unpkg.com to jsdelivr.com. Unfortunately, this won’t help any of the users linking to unpkg.com per previous instructions so I’d still like to find a solution to this if possible.

@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

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)

@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.

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

I can confirm it’s fixed here. 👍

@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 if it’s cloudflare still caching, can’t you force a purge cache with them?

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

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

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

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