Why
Several anonymous read paths load whole Git blobs into memory:
server/web/codebrowser.go:180—Blob/Rawusesg.BlobAt, which reads the entire blob before truncating or displaying.server/web/overview.go—readmeAtdoes the same for a README.server/pages/catfile.go— thecat-file --batchpool allocates the full object for every site read.metadata.LoadIssues/LoadRequestsread every metadata blob in full.
A single large blob in a public repository can cause a large allocation per concurrent request.
Scope
- Add a blob-size query and a capped prefix-read helper.
- Stream
/raw, release, LFS, and artifact downloads instead of buffering. - Cap inline rendering, README size, site blob size, and syntax-highlight input.
- Add metadata file size and count limits, enforced at web-write and pre-receive.
- Return a clear
413/truncated response instead of silently allocating.
Acceptance
- A 50–100 MiB blob is served or rejected without proportional per-request heap growth.
- Tests cover
Blob,Raw, README, pages, and metadata loading.