Repository navigation
Conversation
A Core Cache body read via `to_stream()` or `to_stream_from_range(..)` was always a channel chunk with no size hint, so hyper framed it as chunked even when the entry's length was known. Production Compute sends `Content-Length` there. Channel chunks now carry an optional count of the bytes they have left to yield, which feeds `Body::size_hint` and `Body::len`. `CollectingBody` keeps the insert's expected length and attaches the exact length of each read when the body's length is known up front or the body is complete. A body that then comes up short still fails, so hyper cuts off the connection instead of ending a chunked response cleanly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without a known length, the host learns an entry's length only after its collector task has read the whole body, which happens asynchronously after the writer finishes. On slower CI runners the guest's lookup won that race, so the body was still chunked. Re-look-up until the length is known, as the cache fixture's poll_known_length does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
When a guest streams a Core Cache entry to the client with
found.to_stream()orto_stream_from_range(..)in automatic framing mode, production Compute sendsContent-Lengthif the entry's length is known. Viceroy sentTransfer-Encoding: chunkedeven for entries inserted withknown_lengththat had finished filling. Because of this, guests can't assertContent-Lengthon cache hits when testing locally.Cause
CollectingBody::read_rangealways returns aChunk::Channel, andBody::size_hintgives up as soon as it sees one. In automatic mode the guest'sContent-Lengthis stripped, so hyper frames the body as chunked.Change
Chunk::Channelgets anOption<u64>: the exact number of bytes the channel still has to yield. It goes down as chunks are read.Body::lenandBody::size_hintboth use it. Because it's stored per chunk, appending other bodies keeps the total correct.CollectingBodynow keeps the expected length from the insert. Each read gets an exact length when the body's length is known, either fromknown_lengthor because the body is complete. For a range, that'smin(end, len) - start. If the length isn't known yet, the read stays chunked, as before.Behaviour change to check
Body::known_length()in the guest now returnsSome(n)for these cache bodies, because the hostcalls useBody::len(). I haven't checked what production returns here. If production returnsNone, we can limit this change tosize_hintonly.Tests
Body: exact hint, the count going down as chunks are read, and append.CollectingBody: full, range and open-ended lengths; unknown length staying unknown until the body completes; an underfilled known-length body failing.cache-framingfixture and integration tests, core wasm and component, sent through hyper:100..=199, open-ended range from 4990, and a finished insert withoutknown_length: each sendsContent-Length;Content-Length: 5000;Content-Lengthis the sum of both;known_length().cargo test --allandclippy -D warningspass. The existing framing tests (framing_headers_are_overridden,manual_framing_preserves_transfer_encoding,content_length_is_computed_correctly) are unchanged.🤖 Generated with Claude Code