mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-17 06:19:41 +02:00
Fix gRPC schema refresh not invalidating cache
The skip_cache flag in services() called reflect(), but reflect() had its own cache check that returned early. Simplified by removing skip_cache and always invalidating the pool in cmd_grpc_reflect, since that command is only called when fresh schema is needed. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -189,7 +189,6 @@ async fn cmd_grpc_reflect<R: Runtime>(
|
|||||||
request_id: &str,
|
request_id: &str,
|
||||||
environment_id: Option<&str>,
|
environment_id: Option<&str>,
|
||||||
proto_files: Vec<String>,
|
proto_files: Vec<String>,
|
||||||
skip_cache: Option<bool>,
|
|
||||||
window: WebviewWindow<R>,
|
window: WebviewWindow<R>,
|
||||||
app_handle: AppHandle<R>,
|
app_handle: AppHandle<R>,
|
||||||
grpc_handle: State<'_, Mutex<GrpcHandle>>,
|
grpc_handle: State<'_, Mutex<GrpcHandle>>,
|
||||||
@@ -224,18 +223,21 @@ async fn cmd_grpc_reflect<R: Runtime>(
|
|||||||
let settings = window.db().get_settings();
|
let settings = window.db().get_settings();
|
||||||
let client_certificate =
|
let client_certificate =
|
||||||
find_client_certificate(req.url.as_str(), &settings.client_certificates);
|
find_client_certificate(req.url.as_str(), &settings.client_certificates);
|
||||||
|
let proto_files: Vec<PathBuf> =
|
||||||
|
proto_files.iter().map(|p| PathBuf::from_str(p).unwrap()).collect();
|
||||||
|
|
||||||
Ok(grpc_handle
|
// Always invalidate cached pool when this command is called, to force re-reflection
|
||||||
.lock()
|
let mut handle = grpc_handle.lock().await;
|
||||||
.await
|
handle.invalidate_pool(&req.id, &uri, &proto_files);
|
||||||
|
|
||||||
|
Ok(handle
|
||||||
.services(
|
.services(
|
||||||
&req.id,
|
&req.id,
|
||||||
&uri,
|
&uri,
|
||||||
&proto_files.iter().map(|p| PathBuf::from_str(p).unwrap()).collect(),
|
&proto_files,
|
||||||
&metadata,
|
&metadata,
|
||||||
workspace.setting_validate_certificates,
|
workspace.setting_validate_certificates,
|
||||||
client_certificate,
|
client_certificate,
|
||||||
skip_cache.unwrap_or(false),
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| GenericError(e.to_string()))?)
|
.map_err(|e| GenericError(e.to_string()))?)
|
||||||
|
|||||||
@@ -340,10 +340,9 @@ impl GrpcHandle {
|
|||||||
metadata: &BTreeMap<String, String>,
|
metadata: &BTreeMap<String, String>,
|
||||||
validate_certificates: bool,
|
validate_certificates: bool,
|
||||||
client_cert: Option<ClientCertificateConfig>,
|
client_cert: Option<ClientCertificateConfig>,
|
||||||
skip_cache: bool,
|
|
||||||
) -> Result<Vec<ServiceDefinition>> {
|
) -> Result<Vec<ServiceDefinition>> {
|
||||||
// Ensure we have a pool; reflect only if missing
|
// Ensure we have a pool; reflect only if missing
|
||||||
if skip_cache || self.get_pool(id, uri, proto_files).is_none() {
|
if self.get_pool(id, uri, proto_files).is_none() {
|
||||||
info!("Reflecting gRPC services for {} at {}", id, uri);
|
info!("Reflecting gRPC services for {} at {}", id, uri);
|
||||||
self.reflect(id, uri, proto_files, metadata, validate_certificates, client_cert)
|
self.reflect(id, uri, proto_files, metadata, validate_certificates, client_cert)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export function useGrpc(
|
|||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
const environmentId = jotaiStore.get(activeEnvironmentIdAtom);
|
const environmentId = jotaiStore.get(activeEnvironmentIdAtom);
|
||||||
return minPromiseMillis<ReflectResponseService[]>(
|
return minPromiseMillis<ReflectResponseService[]>(
|
||||||
invokeCmd('cmd_grpc_reflect', { requestId, protoFiles, environmentId, skipCache: true }),
|
invokeCmd('cmd_grpc_reflect', { requestId, protoFiles, environmentId }),
|
||||||
300,
|
300,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user