Always update response if error

https://feedback.yaak.app/p/cant-re-send-request-if-there-is-one-ongoing
This commit is contained in:
Gregory Schier
2025-07-10 12:51:04 -07:00
parent f745435d26
commit 840f15c997
2 changed files with 52 additions and 18 deletions

View File

@@ -167,9 +167,9 @@ pub async fn send_http_request<R: Runtime>(
let cookies = cj let cookies = cj
.cookies .cookies
.iter() .iter()
.map(|cookie| { .filter_map(|cookie| {
let json_cookie = serde_json::to_value(cookie).unwrap(); let json_cookie = serde_json::to_value(cookie).ok()?;
serde_json::from_value(json_cookie).expect("Failed to deserialize cookie") serde_json::from_value(json_cookie).ok()?
}) })
.map(|c| Ok(c)) .map(|c| Ok(c))
.collect::<Vec<Result<_>>>(); .collect::<Vec<Result<_>>>();

View File

@@ -837,13 +837,18 @@ async fn cmd_call_http_request_action<R: Runtime>(
req: CallHttpRequestActionRequest, req: CallHttpRequestActionRequest,
plugin_manager: State<'_, PluginManager>, plugin_manager: State<'_, PluginManager>,
) -> YaakResult<()> { ) -> YaakResult<()> {
Ok(plugin_manager.call_http_request_action(&window, CallHttpRequestActionRequest { Ok(plugin_manager
args: CallHttpRequestActionArgs { .call_http_request_action(
http_request: resolve_http_request(&window, &req.args.http_request)?.0, &window,
..req.args CallHttpRequestActionRequest {
}, args: CallHttpRequestActionArgs {
..req http_request: resolve_http_request(&window, &req.args.http_request)?.0,
}).await?) ..req.args
},
..req
},
)
.await?)
} }
#[tauri::command] #[tauri::command]
@@ -852,13 +857,18 @@ async fn cmd_call_grpc_request_action<R: Runtime>(
req: CallGrpcRequestActionRequest, req: CallGrpcRequestActionRequest,
plugin_manager: State<'_, PluginManager>, plugin_manager: State<'_, PluginManager>,
) -> YaakResult<()> { ) -> YaakResult<()> {
Ok(plugin_manager.call_grpc_request_action(&window, CallGrpcRequestActionRequest { Ok(plugin_manager
args: CallGrpcRequestActionArgs { .call_grpc_request_action(
grpc_request: resolve_grpc_request(&window, &req.args.grpc_request)?.0, &window,
..req.args CallGrpcRequestActionRequest {
}, args: CallGrpcRequestActionArgs {
..req grpc_request: resolve_grpc_request(&window, &req.args.grpc_request)?.0,
}).await?) ..req.args
},
..req
},
)
.await?)
} }
#[tauri::command] #[tauri::command]
@@ -980,7 +990,31 @@ async fn cmd_send_http_request<R: Runtime>(
None => None, None => None,
}; };
send_http_request(&window, &request, &response, environment, cookie_jar, &mut cancel_rx).await let r = match send_http_request(
&window,
&request,
&response,
environment,
cookie_jar,
&mut cancel_rx,
)
.await
{
Ok(r) => r,
Err(e) => {
let resp = app_handle.db().get_http_response(&response.id)?;
app_handle.db().upsert_http_response(
&HttpResponse {
state: HttpResponseState::Closed,
error: Some(e.to_string()),
..resp
},
&UpdateSource::from_window(&window),
)?
}
};
Ok(r)
} }
fn response_err<R: Runtime>( fn response_err<R: Runtime>(