Repository navigation
fix(server): answer stdio clients while the stores are loading - #26
Merged
Merged
Conversation
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.
What does this PR do?
Stops stdio clients from timing out while the server is still loading its stores.
initializeis answered immediately.tools/listreturns the list derived from configuration, and other calls return a clearstartingerror.This does not make startup faster. Under CPU starvation the first working search still takes minutes, and calls return
startinguntil then.Why?
Startup loads the memory cache and the vector index synchronously, and a stdio client had to wait for all of it on
initialize. On a heavily loaded machine that wait exceeds client timeouts, so the client fails without a useful error.Measurements used the real binary on a copy of a memory bank, with the process limited to 2% CPU and a 30-second client timeout:
initializetools/liststartingerrors before itThe search numbers differ within run-to-run noise and show neither a speedup nor a slowdown.
Known follow-up: lazy loading of the memory cache is the actual fix for slow startup and needs a separate refactoring of
internal/memory.How to test
make vetgo test -race ./...initialize,tools/listand a search call.Not verified: a cold filesystem cache, the original multi-minute scenario with heavy swap, and live Claude Code or Codex clients. CLI commands and hooks still load the same cache on every run; their timing was not measured. If a store fails to open after the 20-second window, tools stay listed but their calls fail. HTTP still answers 503 during startup.
Checklist
go test ./...passesgo vet ./...passes