You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I enter on my profile, the stats fails to load on the first run.
They only load successfully when I reload the page.
Tested it, and this is happening both on my own and on other computers.
Expected behaviour
The stats should load on the first run.
Screenshots / Live demo link
Additional context
I'm using the feature as a Vercel instance.
I'm using the feature as a HTML image.
@VianaSamuel Thanks for your bug report. This is a known issue. It is caused by a timeout in the GitHub CDN and therefore something that is very hard to debug (see #2446 (comment)). I think we will switch to a GitHub action in the future to see if that solves the issue (see #2179). Otherwise, we might have to improve the card generation code (see #1633).
Hinted by @Zo-Bro-23's #2537, we can also create a GitHub action in .github/workflows to cache the svg from your own vercel instance to avoid this to happen by using actions-download-file.
name: Cache Actionon:
workflow_dispatch:
schedule:
- cron: 0 */4 * * * # Every 4 hours, change it accordinglyjobs:
stats:
permissions: write-allruns-on: ubuntu-latestname: Stats Cardsteps:
- uses: actions/checkout@v3name: Check out current commit
- uses: suisei-cn/actions-download-file@v1.3.0id: statsname: Download the stats filewith:
url: "https://github-readme-stats.vercel.app/api?username=username"# Put your own vercel instance URL heretarget: grsfilename: stats.svg # Need to have the file name prepared as svg
- uses: actions/upload-artifact@masterwith:
name: statspath: grspush:
permissions: write-allruns-on: ubuntu-latestname: Pushneeds: [stats] # Put any jobs (card) needed here before we pushsteps:
- uses: actions/download-artifact@masterwith:
name: statspath: grs
- name: Pushuses: crazy-max/ghaction-github-pages@v3with:
target_branch: resource/grs # May change to your desired branch name, the final URL need to be updated if you change thisbuild_dir: grsenv:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Just replace the URL with your own vercel instance URL.
Then, you can update the final URL of the source in read.me to be https://github.com/USERNAME/USERNAME/raw/resource/grs/stats.svg
Hinted by @Zo-Bro-23's #2537, we can also create a GitHub action in .github/workflows to cache the svg from your own vercel instance to avoid this to happen by using actions-download-file.
name: Cache Actionon:
workflow_dispatch:
schedule:
- cron: 0 */4 * * * # Every 4 hours, change it accordinglyjobs:
stats:
permissions: write-allruns-on: ubuntu-latestname: Stats Cardsteps:
- uses: actions/checkout@v3name: Check out current commit
- uses: suisei-cn/actions-download-file@v1.3.0id: statsname: Download the stats filewith:
url: "https://github-readme-stats.vercel.app/api?username=username"# Put your own vercel instance URL heretarget: grsfilename: stats.svg # Need to have the file name prepared as svg
- uses: actions/upload-artifact@masterwith:
name: statspath: grspush:
permissions: write-allruns-on: ubuntu-latestname: Pushneeds: [stats] # Put any jobs (card) needed here before we pushsteps:
- uses: actions/download-artifact@masterwith:
name: statspath: grs
- name: Pushuses: crazy-max/ghaction-github-pages@v3with:
target_branch: resource/grs # May change to your desired branch name, the final URL need to be updated if you change thisbuild_dir: grsenv:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Just replace the URL with your own vercel instance URL. Then, you can update the final URL of the source in read.me to be https://github.com/USERNAME/USERNAME/raw/resource/grs/stats.svg
@YanbingJiang, thanks a lot for sharing your workaround ❤️🔥. Although it still requires users to deploy a Vercel instance, it is a good workaround until #2537 is released!
Reacted by Scott Ginn, Yanbing Jiang and Abhijit Paul
I'm experiencing this issue as well; it could be due to the cold start of the functions.
@wonrax This could also be the reason if the issue only happens on private instances 🤔. For the public instance since so many users use it, I wouldn't expect the cold start to be a problem. To solve this, we could switch to edge functions. Our priority is releasing the GitHub action so that users have another option for using GRS (see #2179). This problem should not exist for the GitHub action.
I've just spun up a val.town function for some testing, and it seems like it confirmed my suspicion. The GitHub readme preview seems to start timing out requests that take around 4 seconds or longer.
Thank you so much @YanbingJiang for the GitHub Action you shared! I'm posting my modified version if it can be useful to anyone.
The main differences are:
uses a simple curl command instead of a GitHub action to download the SVG files
commits the SVG files to a Git directory instead of GitHub Pages
use pinned versions for GitHub Actions
also downloads the top languages card
Note: I'm using a GitHub PAT instead of permissions since I was already using that for muesli/readme-scribe, but you can easily revert to the permission model used in the original solution!
Activity
rickstaa commentedon Apr 8, 2023
@VianaSamuel Thanks for your bug report. This is a known issue. It is caused by a timeout in the GitHub CDN and therefore something that is very hard to debug (see #2446 (comment)). I think we will switch to a GitHub action in the future to see if that solves the issue (see #2179). Otherwise, we might have to improve the card generation code (see #1633).
VianaSamuel commentedon Apr 12, 2023
@rickstaa Got it! Thanks for the feedback.
YanbingJiang commentedon Aug 19, 2023
Hi there @VianaSamuel @rickstaa,
Hinted by @Zo-Bro-23's #2537, we can also create a GitHub action in
.github/workflowsto cache the svg from your own vercel instance to avoid this to happen by using actions-download-file.Just replace the URL with your own vercel instance URL.
Then, you can update the final URL of the source in read.me to be
https://github.com/USERNAME/USERNAME/raw/resource/grs/stats.svgSimilar issue: #2446
rickstaa commentedon Sep 11, 2023
@YanbingJiang, thanks a lot for sharing your workaround ❤️🔥. Although it still requires users to deploy a Vercel instance, it is a good workaround until #2537 is released!
Update README.md, introduced Github caching to solve stats images not…
Create cache-stat-image.yml for GIthub Action to cache stat image.
wonrax commentedon Sep 18, 2023
I'm experiencing this issue as well; it could be due to the cold start of the functions.
rickstaa commentedon Sep 18, 2023
@wonrax This could also be the reason if the issue only happens on private instances 🤔. For the public instance since so many users use it, I wouldn't expect the cold start to be a problem. To solve this, we could switch to edge functions. Our priority is releasing the GitHub action so that users have another option for using GRS (see #2179). This problem should not exist for the GitHub action.
wonrax commentedon Sep 18, 2023
I've just spun up a val.town function for some testing, and it seems like it confirmed my suspicion. The GitHub readme preview seems to start timing out requests that take around 4 seconds or longer.
Also in Vercel docs:
This lines up with my test results too.
sheerlox commentedon Sep 29, 2023
Thank you so much @YanbingJiang for the GitHub Action you shared! I'm posting my modified version if it can be useful to anyone.
The main differences are:
curlcommand instead of a GitHub action to download the SVG filesNote: I'm using a GitHub PAT instead of permissions since I was already using that for
muesli/readme-scribe, but you can easily revert to the permission model used in the original solution!Source: my own
.github/workflows/github-readme-stats.ymlfileImages URLs used in my
README.mdare then simply"assets/stats.svg"and"assets/top-langs.svg".Fix stats failing to load on the first run
Fix stats failing to load on the first run
swiftyfinch commentedon Nov 28, 2023
Thanks you everyone to share your solutions! ❤️
I also would like to share an another solution w/o additional GitHub actions:
Update grs.yml