Repository navigation
Conversation
ReadMetadataSized took the transport's io.ErrUnexpectedEOF for the end of a body shorter than its size hint. A document upstream closed before its Content-Length was served with a 200 and cached, or failed the cooldown filter with a 502, instead of the cached copy being served. Upstream bodies are now read through a reader that marks their read errors, and such a body fails the read as an upstream failure.
simonchrz
added a commit
to simonchrz/proxy
that referenced
this pull request
Nov 1, 2026
The change to ReadMetadataSized and fetchUpstreamMetadata, with its tests, is now git-pkgs#649. upstreamBodyReader stays for storeUpstreamMetadata, in a file of its own that git-pkgs#649 adds with the same content.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #640, as asked there.
ReadMetadataSizedtook the transport'sio.ErrUnexpectedEOFfor the end of a body shorter than its size hint. So when upstream closed the connection before itsContent-Length, the half document was read as complete: without cooldown it was served with a 200 and cached, with cooldown it failed the filter with a 502. In both cases the cached copy should have been served. This affects every ecosystem that reads metadata throughfetchUpstreamMetadata.Upstream bodies are now read through
upstreamBodyReader, which marks their read errors, andReadMetadataSizedfails on such an error instead of treating it as the end of the body. The upstream failure then falls back to the cached copy as usual. A body that is just shorter than its size hint is still read.Tests:
TestReadMetadataSizedTruncatedUpstream: a cut-off upstream body fails, a short body still reads.TestMetadataTruncatedUpstream: through the npm handler, with and without cooldown, the cached copy is served and not replaced.TestMetadataTruncatedUpstreamUncached: with nothing cached, 502 and nothing cached.The handler tests fail on main.