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

Streak Card not fetching in Readme file #601

Open
keshav-chandra opened this issue Sep 27, 2023 · 3 comments
Open

Streak Card not fetching in Readme file #601

keshav-chandra opened this issue Sep 27, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@keshav-chandra
Copy link

keshav-chandra commented Sep 27, 2023

Describe the bug
When I used GitHub's Streak URL in browser it was showing the streak card but when I had put it in ReadMe file it showed alternate text and link. May be due to the loading time of this API call as it always takes more than 20 seconds or sometimes failed to load and reflect application error.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://github.com/keshav-chandra'
  2. Click on 'Readme.md'
  3. Scroll down to 'GitHub Stats'
  4. See error

Expected behavior
Using this https://streak-stats.demolab.com/?user=keshav-chandra&theme=calm link SVG or PNG, it should have shown the below result.

image

Screenshots
image

Desktop (please complete the following information):

  • OS: [Windows 11]
  • Browser [Chrome]
  • Version [116.0.5845.188]
@keshav-chandra keshav-chandra added the bug Something isn't working label Sep 27, 2023
@DenverCoder1
Copy link
Owner

DenverCoder1 commented Sep 27, 2023

When there is a lot of traffic to the Heroku server, the GitHub API seems to stop sending back content and the responses become very slow. If it takes too long to load, GitHub will just show a broken image instead of waiting. GitHub also caches responses on their server, so even if the speed gets back to normal, it could still show as broken on GitHub for a particular image URL for up to a few hours.

To avoid this issue, I recommend self-hosting the project. There are steps in the readme, I recently added a new method for deploying with Vercel entirely online. It's free and shouldn't take more than a couple minutes to set up.

It should also start working on its own, but there isn't much I can do to prevent it from going down in the future, so self-hosting is still an option to get it to stay up more reliably.

@XiovV
Copy link

XiovV commented Oct 5, 2023

When there is a lot of traffic to the Heroku server, the GitHub API seems to stop sending back content and the responses become very slow. If it takes too long to load, GitHub will just show a broken image instead of waiting. GitHub also caches responses on their server, so even if the speed gets back to normal, it could still show as broken on GitHub for a particular image URL for up to a few hours.

To avoid this issue, I recommend self-hosting the project. There are steps in the readme, I recently added a new method for deploying with Vercel entirely online. It's free and shouldn't take more than a couple minutes to set up.

It should also start working on its own, but there isn't much I can do to prevent it from going down in the future, so self-hosting is still an option to get it to stay up more reliably.

@DenverCoder1 why not set up caching on the backend? Instead of calling the GitHub API on every request, you can cache a user's stats for a few hours and have it clear itself automatically, that way the number of calls do the GitHub API should reduce dramatically. Yes, the PNG won't pick up your new streak immediately until the cache invalidates, but this should be much better than GitHub showing a broken image. Considering how lightweight and simple this project is, I don't think you'd even have to use Redis or something similar for caching, just a regular hashmap and it should work fine (unless you're running multiple instances on the heroku server that is).

@DenverCoder1
Copy link
Owner

Thanks for the suggestions, @XiovV.

I believe that GitHub is caching the images, but even with that, the server is overloaded with new requests. We have cache control headers set to tell servers to use cached versions for up to an hour. Maybe increasing this to be a few hours could help.

Only 1 instance is running on Heroku (using a Basic dyno formation). There is no persistent storage, but an external service could be used for caching if necessary, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants