Repository navigation
fix: a failed API request no longer terminates the server. - #303
Merged
Merged
Conversation
The HTTP accept loop only caught NnTransferSocketException and HttpRequestException. Any other std::exception thrown while handling a request (e.g. a json type error on a syntactically valid but malformed body, or a tokenizer error) propagated out of runHttpServer uncaught and aborted the whole process. Catch std::exception per connection and keep serving. NnExecutorException and NnConnectionSocketException are rethrown so the existing retry loop in main() still restarts the app when inference or the cluster link is actually broken. Ported from hellomatik-org/distributed-llama (pi5-cluster, c6c601d), adapted to the extracted http.cpp and its retry-loop semantics. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
|
Thanks! |
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.
The HTTP accept loop only caught NnTransferSocketException and HttpRequestException. Any other std::exception thrown while handling a request (e.g. a json type error on a syntactically valid but malformed body, or a tokenizer error) propagated out of runHttpServer uncaught and aborted the whole process.
Catch std::exception per connection and keep serving. NnExecutorException and NnConnectionSocketException are rethrown so the existing retry loop in main() still restarts the app when inference or the cluster link is actually broken.
Ported from hellomatik-org/distributed-llama (pi5-cluster, c6c601d), adapted to the extracted http.cpp and its retry-loop semantics.
Tested by building with make dllama-api and running dllama-api with qwen3-30b-a3b q40 (no workers, x86 AVX2). I sent a syntactically valid request with a wrongly typed field, {"messages":[{"role":"user","content":"hi"}],"stream":"yes"}, to /v1/chat/completions. parseInferenceParams calls get() on "stream" and throws a json type_error.
Before this change (main), the process aborts: "terminate called after throwing an instance of 'nlohmann::json_abi_v3_11_3::detail::type_error' what(): [json.exception.type_error.302] type must be boolean, but is string", followed by "Aborted (core dumped)". A following GET /v1/models gets no response because the server is gone.
With this change, the server logs "Request error: [json.exception.type_error.302] type must be boolean, but is string" and keeps running, and a following GET /v1/models returns the model list normally.