Skip to content
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

hotfix for statusText is non ISO-8859-1 #5717 #5719

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/utils/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export function fetch(url: string, options?: RequestInit): Promise<any> {
})
.catch((e) => {
console.error("stream error", e);
throw e;
// throw e;
return new Response("", { status: 599 });
lloydzhou marked this conversation as resolved.
Show resolved Hide resolved
});
}
return window.fetch(url, options);
Expand Down
13 changes: 11 additions & 2 deletions src-tauri/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,20 @@ pub async fn stream_fetch(
}
}
Err(err) => {
println!("Error response: {:?}", err.source().expect("REASON").to_string());
let error: String = err.source().expect("REASON").to_string();
println!("Error response: {:?}", error);
tauri::async_runtime::spawn( async move {
if let Err(e) = window.emit(event_name, ChunkPayload{ request_id, chunk: error.into() }) {
println!("Failed to emit chunk payload: {:?}", e);
}
if let Err(e) = window.emit(event_name, EndPayload{ request_id, status: 0 }) {
println!("Failed to emit end payload: {:?}", e);
}
});
lloydzhou marked this conversation as resolved.
Show resolved Hide resolved
StreamResponse {
request_id,
status: 599,
status_text: err.source().expect("REASON").to_string(),
status_text: "Error".to_string(),
headers: HashMap::new(),
}
}
Expand Down