Severe transfer degradation and connection resets when downloading individual files from private repository via REST API #208090
Replies: 1 comment 1 reply
|
Your connectivity is clearly fine (tarball at 3.2 MB/s, public archive at 2.5 MB/s), so this is specific to the authenticated raw/blob single-object path — not your server. Two things are going on, and both are best solved by switching retrieval path: 1. The Contents API isn't built for binary/file streaming. 2. Use the Git Blobs API for individual files (the supported path, up to 100 MB): TOKEN=...
sha=$(curl -sH "Authorization: token $TOKEN" -H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/mjmokhtar/docs-for-learning/contents/career/roadmap.png" | jq -r .sha)
curl -sH "Authorization: token $TOKEN" -H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/mjmokhtar/docs-for-learning/git/blobs/$sha" \
| jq -r .content | tr -d '\n' | base64 -d > roadmap.pngThe blob endpoint returns base64 ( 3. For raw bytes directly, point at the raw host instead of api.github.com: curl -sH "Authorization: token $TOKEN" \
"https://raw.githubusercontent.com/mjmokhtar/docs-for-learning/main/career/roadmap.png" -o roadmap.pngWorth adding Since tarball is orders of magnitude faster than single raw objects, this also smells like a cold-object/CDN stall on the authenticated raw path — worth a staff look — but the Blobs API above unblocks you right now. |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Question
Body
Hello GitHub Support,
I am experiencing a reproducible issue when downloading individual files from a private repository through the GitHub REST API.
Repository: mjmokhtar/docs-for-learning
The Contents API successfully returns metadata, authentication works correctly, and downloading the entire private repository archive works normally. However, requesting individual binary files using the raw media type becomes extremely slow and eventually terminates or is reset.
Example request:
GET /repos/mjmokhtar/docs-for-learning/contents/career/roadmap.png
with:
Accept: application/vnd.github.raw
One reproduction resulted in:
HTTP: 200
Expected file size: ~372 KB
Received: 162426 bytes
Average speed: 533 bytes/sec
Duration: 304 seconds
curl: (56) Recv failure: Connection reset by peer
A 2.38 MB PDF from the same repository also repeatedly fails. Node.js/Undici reports:
UND_ERR_SOCKET: other side closed
In contrast, downloading the entire private repository archive through:
GET /repos/mjmokhtar/docs-for-learning/tarball/main
successfully transferred approximately 1.69 GB at ~3.2 MB/s.
A public repository archive downloaded through api.github.com also transferred approximately 12 MB in 4.75 seconds (~2.5 MB/s).
Therefore, general connectivity from this server to GitHub appears healthy. The degradation seems specific to individual authenticated raw/blob file delivery.
I can reproduce the problem directly with curl, without my application, reverse proxy, or Cloudflare involved.
Could you please investigate whether there is an issue with the backend/CDN path serving authenticated raw/blob objects for private repositories, or advise what additional diagnostics would help identify the problem?
Thank you.
All reactions