fix(logs): classify web-search client aborts as 499, not upstream 502#158
Closed
Wibias wants to merge 2 commits into
Closed
fix(logs): classify web-search client aborts as 499, not upstream 502#158Wibias wants to merge 2 commits into
Wibias wants to merge 2 commits into
Conversation
Mid-stream web-search cancels were emitted as response.failed with 'client closed request during web-search', then inferred as 502 / upstream_server_error. Map those messages to 499 client_closed_request and client_cancel in /api/logs.
…mpact Keep formatErrorResponse(499, client_cancelled, ...) stable while still mapping web-search abort messages onto client_closed_request.
lidge-jun
pushed a commit
that referenced
this pull request
Jul 19, 2026
Mid-stream web-search cancels were emitted as response.failed with 'client closed request during web-search', then inferred as 502 / upstream_server_error. Map those messages to 499 client_closed_request and client_cancel in /api/logs. (cherry picked from commit 57d8794) Community PR #158 absorb; source head 67b660b.
lidge-jun
added a commit
that referenced
this pull request
Jul 19, 2026
Repairs for community PR #158 absorb (source head 67b660b), Sol review findings: - isClientClosedMessage no longer matches bare 'client closed' / 'client cancelled' substrings, which could reclassify a legitimate upstream 502 ('upstream HTTP client closed idle connection') as a 499 client cancel. The matcher now covers only phrases this codebase produces: 'client closed request' (web-search loop), 'Client cancelled/canceled request' (responses.ts), and the explicit 'request cancel(l)ed by client' forms. - Negative tests pin the narrowness: upstream closed-connection wordings stay 502/upstream_server_error. - Compact-path activation: bufferCompactResponse exported as the narrow seam and driven with a real mid-buffer AbortSignal — the 499 client_cancelled branch is now observed firing, not just the formatter. Co-authored-by: Wibias <37517432+Wibias@users.noreply.github.com>
Owner
|
Thanks — mid-stream web-search cancels masquerading as upstream 502s was a real logging bug, and it's landed on
Full suite green (3,087 tests). Closing in favor of the dev-landed commits; ships with the next release. |
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.
Summary
response.failedwithclient closed request during web-search.502/upstream_server_errorwithcloseReason: terminal, which looked like a Kimi upstream failure.499/client_closed_request/closeReason: client_cancel, including a legacy remap when a 5xx log still carries that reason.client_cancelledJSON errors used by combo/compact paths.This does not change Kimi itself or stop web-search sidecar behavior — it fixes log/error classification so cancels are not mistaken for provider outages.
Test plan
bun test tests/errors-adapter-failure.test.ts tests/request-log.test.ts tests/web-search.test.tsbun test tests/server-combo-failover-e2e.test.ts -t ""connect cancellation""kimi/k3) and confirm/api/logsshows499+client_closed_request+client_cancel