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

request: remove 404 HTTP status code on failed npm requests #514

Open
privatenumber opened this issue Mar 5, 2021 · 5 comments
Open

request: remove 404 HTTP status code on failed npm requests #514

privatenumber opened this issue Mar 5, 2021 · 5 comments

Comments

@privatenumber
Copy link

When using getting the npm monthly downloads, new packages return a 404 HTTP status. For example: https://badgen.net/npm/dm/fs.promises.exists

Screen Shot 2021-03-04 at 10 57 30 PM

The 404 HTTP status code prevents the image from being embedded at all, showing a broken image instead:
Screen Shot 2021-03-04 at 10 56 29 PM

I would much rather have the 404 npm badge displayed (via HTTP status code 200) temporarily than a broken image embed.

Is it possible to remove the 404 status code?

Happy to PR if so.

@vladimyr
Copy link
Contributor

vladimyr commented Mar 5, 2021

The 404 HTTP status code prevents the image from being embedded at all, showing a broken image instead

Are you sure that the actual response status code is 404? I did a quick test using:

curl -i https://badgen.net/npm/dm/fs.promises.exists

and got back badge with 500 instead 😕

@privatenumber
Copy link
Author

My mistake, I meant 500. (Got confused since the text displays 404).

Would like it to return 200 instead, because it's responding with an image worth displaying/embedding.

@vladimyr
Copy link
Contributor

vladimyr commented Mar 5, 2021

I would much rather have the 404 npm badge displayed (via HTTP status code 200) temporarily than a broken image embed.

Is it possible to remove the 404 status code?

Happy to PR if so.

With that being said I don't know what @amio thinks about it but to me, it makes sense to go with a successful response code with an on-badge error indication due to reasons you just explained and because shields.io does the same.

@vladimyr
Copy link
Contributor

vladimyr commented Mar 5, 2021

Error handling in general needs some love 🙃

@amio
Copy link
Member

amio commented Apr 6, 2021

it makes sense to go with a successful response code with an on-badge error indication

Overall I'm agree with this 👍

IIRC GitHub would cache image with status code 200 for hours, that's the reason I made it an error response, to prevent GitHub cache an incorrect badge.

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

No branches or pull requests

3 participants