Repository navigation
Conversation
Bodies over the buffered limit returned truncated bytes, so every npm packument over 10 MiB failed to decode. Buffered reads now return ErrResponseTooLarge, and npm packuments are decoded from the body. Claude-Session: https://claude.ai/code/session_01NxsA75HBjdWQKcdx7FDTDc
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
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.
Closes #29
client.Clientread bodies throughio.LimitReaderat 10 MiB and returned the truncated bytes with no error, so every npm full packument over that size failed withunexpected end of JSON input: renovate, next, typescript, @types/node and aws-sdk among them (numbers in #29).Buffered reads (
GetBody,GetJSON,GetText) now read one byte past the limit and returnErrResponseTooLargewhen it arrives, without retrying. The limit is per client:MaxResponseSizeorWithMaxResponseSize, defaulting to 10 MiB as before.StreamJSON(ctx, url, fn)passes ajson.Decoderover the response body tofn, with the same retries for getting a response and its own limit (MaxStreamSize,WithMaxStreamSize, default 512 MiB) that also fails withErrResponseTooLargerather than ending the stream early. The request and retry loop is split out asopen, which returns the response with its body unread, so both paths share it.All five npm reads (
FetchPackage,FetchVersions,FetchVersion,FetchDependencies,FetchMaintainers) now decode the packument from the body: top-level fields into a header, each entry inversionsdecoded or skipped as it arrives, so the document is never held whole.timecomes afterversionson registry.npmjs.org, so publication times are filled in at the end.FetchPackagedecodes only thelatestversion whendist-tagsarrives first, and keeps versions raw only when it doesn't.Against registry.npmjs.org, renovate (72.6 MB, 5747 versions) now resolves with a peak heap of 22 MB, and next, typescript, vite and aws-sdk all resolve with publication times on every version. On a local copy of renovate's packument, raising the limit and decoding into the old structs instead peaked at about 148 MB on top of the 72.6 MB body.
https://claude.ai/code/session_01NxsA75HBjdWQKcdx7FDTDc