Repository navigation
fix: Record a client that leaves before the head as client_canceled #1777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -544,7 +544,9 @@ impl Exchange { | |
| None => format!("request body over the {MAX_REQUEST_BODY}-byte buffer limit"), | ||
| }; | ||
| (413, ("proxy_error", String::new(), message)) | ||
| } else if downstream_gone || status == 499 { | ||
| // Status 0: Praxis wrote nothing to the client, so the client left | ||
| // before any answer (an upstream failure is written as 502). | ||
| } else if downstream_gone || status == 499 || status == 0 { | ||
| (499, ("client_canceled", code, CLIENT_GONE.to_owned())) | ||
| } else if upstream_gone { | ||
| ( | ||
|
|
@@ -1138,6 +1140,21 @@ mod tests { | |
| } | ||
| } | ||
|
|
||
| // Seen in the #1725 live check: the agent exited while the hop waited for | ||
| // the head, so Praxis wrote nothing and gave status 0. | ||
| #[test] | ||
| fn deferred_nothing_written_is_client_canceled() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: This unit test pins #[test]
fn client_leaves_before_head_is_client_canceled() {
let o = origin(|_, s| {
std::thread::sleep(Duration::from_millis(1500));
respond(s, "200 OK", &[("Content-Type", "text/plain")], b"ok");
});
let i = ingest();
let g = gateway(&o, &i, true);
let mut s = g.connect();
s.write_all(&head("GET", "/v1/models", &[("X-Cortex-Token", TOKEN)], 0))
.expect("head");
std::thread::sleep(Duration::from_millis(300));
let _ = s.shutdown(Shutdown::Both);
let lines = i.take(2);
let resp = response_row(&lines);
assert_eq!(resp["event"]["statusCode"], 499);
assert_eq!(resp["event"]["error"]["kind"], "client_canceled");
} |
||
| let f = fixture(); | ||
| let mut ex = exchange("GET", "api.example.com", &f.target, &f.req_headers); | ||
| let rows: Vec<Value> = ex.deferred(0, false, false).iter().map(json_of).collect(); | ||
| assert_eq!(rows.len(), 2); | ||
| assert_eq!(rows[1]["event"]["statusCode"], 499); | ||
| assert_eq!( | ||
| rows[1]["event"]["error"], | ||
| json!({"kind": "client_canceled", "message": CLIENT_GONE}) | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn deferred_upstream_gone_is_upstream_error() { | ||
| let rows = streaming_exchange().deferred(200, false, true); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This line is now 109 columns and the rest of the block wraps near 80.
rustfmtdoes not wrap comments, so it is worth rewrapping by hand.