Skip to content

fix: stop listing harvest results when the client is gone or there are too many - #1641

Open
bielu wants to merge 2 commits into
clearlydefined:masterfrom
bielu:fix/harvest-list-abort-limit
Open

bielu wants to merge 2 commits into
clearlydefined:masterfrom
bielu:fix/harvest-list-abort-limit

Conversation

@bielu

@bielu bielu commented Oct 11, 2026

Copy link
Copy Markdown

Refs #1636. Stacked on #1638: the first commit here is that PR, only the second commit is new.

GET /harvest/...?form=list builds the whole list before sending anything, and the time that takes grows with the number of matching blobs. Measured against api.clearlydefined.io (uncached):

Coordinates Results Time
nuget/nuget/-/Newtonsoft.Json 1,545 5.0 s
npm/npmjs/-/lodash 25,632 50.8 s
npm/npmjs/-/typescript 37,657 51.5 s
npm/npmjs/-/react no response in 100 s

Nothing stops the loop once the client has timed out, and a request such as /harvest/npm asks for the whole container.

Changes

  • The store's list takes an optional { signal, limit }. It checks both before fetching each page.
  • The harvest route aborts the listing when the response is closed.
  • The harvest route answers 400 More than 100000 results, use more specific coordinates instead of listing further. 100,000 is more than a request can list within the 100 second edge timeout today.

Other callers of list pass no options and behave as before. The file store ignores the options; the route still applies the limit to its result.

An aborted listing stops before the next page; the storage request already in flight is not cancelled.

Testing

  • Store tests for paging, the limit and aborting; route tests for the 200, the 400 and a closed response.
  • tsc and biome check pass. Mocha: 844 passing, 3 failing locally; the same 3 fail on master on my machine (Redis needs a container runtime, the Mongo memory server fails to spawn on Windows).
  • Not run against real blob storage.

🤖 Generated with Claude Code

bielu and others added 2 commits October 11, 2026 23:16
Listing harvest results for partial coordinates used the storage path as a
raw blob prefix, so `foo` also listed `foo.bar` and `1.0` also listed
`1.0-beta`, and a short name scanned every blob whose name starts with it.
End the prefix with `/` unless it already identifies a single tool version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e too many

Listing walks every matching blob before anything is sent and kept doing
so after the client had timed out. Stop when the response is closed, and
answer 400 rather than list more than 100000 results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant