Skip to content

Incorrect redirection leading to not found js #156

Closed

Description

@antoniandre

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 [email protected], 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/[email protected]/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!

Activity

  1. smellyshovel commented on Dec 18, 2018

    @smellyshovel

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

  2. balazsbajorics commented on Dec 18, 2018

    @balazsbajorics

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

  3. jukben commented on Dec 18, 2018

    @jukben

    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 😞

  4. davidmsibley commented on Dec 18, 2018

    @davidmsibley

    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

  5. davidmsibley commented on Dec 18, 2018

    @davidmsibley

    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

  6. added a commit that references this issue on Dec 18, 2018
    68fddea
  7. jgravois commented on Dec 18, 2018

    @jgravois
    Contributor

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

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

  8. davidmsibley commented on Dec 18, 2018

    @davidmsibley

    @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

  9. antoniandre commented on Dec 19, 2018

    @antoniandre
    Author

    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/[email protected]/dist/splitpanes.umd.min.js)

  10. AKPWebDesign commented on Dec 20, 2018

    @AKPWebDesign

    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

  11. danopia commented on Dec 20, 2018

    @danopia
  12. dead-claudia commented on Dec 20, 2018

    @dead-claudia

    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").

  13. antoniandre commented on Dec 20, 2018

    @antoniandre
    Author

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

  14. 23 remaining items

  15. mjackson commented on Jan 2, 2019

    @mjackson
    Member

    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.

  16. lbogdan commented on Jan 2, 2019

    @lbogdan

    I can confirm it's fixed here. 👍

  17. Sphinxxxx commented on Jan 2, 2019

    @Sphinxxxx

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

  18. jgravois commented on Jan 2, 2019

    @jgravois
    Contributor

    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: /[email protected]
    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.

  19. porsager commented on Jan 2, 2019

    @porsager
  20. Sphinxxxx commented on Jan 2, 2019

    @Sphinxxxx

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

  21. jgravois commented on Jan 2, 2019

    @jgravois
    Contributor

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

  22. mjackson commented on Jan 3, 2019

    @mjackson
    Member

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

  23. porsager commented on Jan 3, 2019

    @porsager

    Awesome! Thanks @mjackson - working here now!

  24. karanisverma commented on Jan 4, 2019

    @karanisverma
  25. jhildenbiddle commented on Jan 5, 2019

    @jhildenbiddle

    Thanks @mjackson. Very much appreciated.

    (Hope this didn't ruin your holidays!)

  26. rogeru commented on Jan 10, 2019

    @rogeru
  27. locked and limited conversation to collaborators on Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions