OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
refactor: Async await fixes (#2033)
Mike Fortman1b2a1fdeec8c
diff --git a/frontend/app/knowledge/page.tsx b/frontend/app/knowledge/page.tsxindex 2f5fcf02b..91629e566 100644--- a/frontend/app/knowledge/page.tsx+++ b/frontend/app/knowledge/page.tsx@@ -791,11 +791,13 @@ function SearchPage() {),);- await refreshTasks();- await queryClient.invalidateQueries({ queryKey: ["search"] });- await queryClient.invalidateQueries({ queryKey: ["listFiles"] });- await queryClient.refetchQueries({ queryKey: ["search"] });- await queryClient.refetchQueries({ queryKey: ["listFiles"] });+ await Promise.all([+ refreshTasks(),+ queryClient.invalidateQueries({ queryKey: ["search"] }),+ queryClient.invalidateQueries({ queryKey: ["listFiles"] }),+ queryClient.refetchQueries({ queryKey: ["search"] }),+ queryClient.refetchQueries({ queryKey: ["listFiles"] }),+ ]);const deleted = deleteResults.filter((diff --git a/frontend/components/dev-role-toggle.tsx b/frontend/components/dev-role-toggle.tsxindex 6e57374fb..689d26150 100644--- a/frontend/components/dev-role-toggle.tsx+++ b/frontend/components/dev-role-toggle.tsx@@ -62,11 +62,13 @@ export function DevRoleToggle() {return response.json() as Promise<{ role?: string }>;},onSuccess: async (data) => {- await refreshPermissions();- await queryClient.invalidateQueries(connectorsQueryFilter);- await queryClient.invalidateQueries({- queryKey: CONNECTOR_USER_ACCESS_KEY,- });+ await Promise.all([+ refreshPermissions(),+ queryClient.invalidateQueries(connectorsQueryFilter),+ queryClient.invalidateQueries({+ queryKey: CONNECTOR_USER_ACCESS_KEY,+ }),+ ]);router.refresh();const label =DEV_ROLES.find((r) => r.value === data.role)?.label ?? data.role;diff --git a/frontend/components/knowledge-dropdown.tsx b/frontend/components/knowledge-dropdown.tsxindex 7e431554b..4a9d03509 100644--- a/frontend/components/knowledge-dropdown.tsx+++ b/frontend/components/knowledge-dropdown.tsx@@ -243,51 +243,53 @@ export function KnowledgeDropdown() {};} = {};- for (const type of cloudConnectorTypes) {- if (connectorsResult.connectors[type]) {- connectorInfo[type] = {- name: connectorsResult.connectors[type].name,- available: connectorsResult.connectors[type].available,- connected: false,- hasToken: false,- };-- // Check connection status+ const availableTypes = cloudConnectorTypes.filter(+ (type) => connectorsResult.connectors[type],+ );++ for (const type of availableTypes) {+ connectorInfo[type] = {+ name: connectorsResult.connectors[type].name,+ available: connectorsResult.connectors[type].available,+ connected: false,+ hasToken: false,+ };+ }++ await Promise.all(+ availableTypes.map(async (type) => {try {const statusRes = await fetch(`/api/connectors/${type}/status`);- if (statusRes.ok) {- const statusData = await statusRes.json();- const connections = statusData.connections || [];- const activeConnection = connections.find(- (conn: { is_active: boolean; connection_id: string }) =>- conn.is_active,+ if (!statusRes.ok) return;++ const statusData = await statusRes.json();+ const connections = statusData.connections || [];+ const activeConnection = connections.find(+ (conn: { is_active: boolean; connection_id: string }) =>+ conn.is_active,+ );+ if (!activeConnection) return;++ connectorInfo[type].connected = true;++ try {+ const tokenRes = await fetch(+ `/api/connectors/${type}/token?connection_id=${activeConnection.connection_id}`,);- const isConnected = activeConnection !== undefined;-- if (isConnected && activeConnection) {- connectorInfo[type].connected = true;-- // Check token availability- try {- const tokenRes = await fetch(- `/api/connectors/${type}/token?connection_id=${activeConnection.connection_id}`,- );- if (tokenRes.ok) {- const tokenData = await tokenRes.json();- if (tokenData.access_token) {- connectorInfo[type].hasToken = true;- }- }- } catch {- // Token check failed+ if (tokenRes.ok) {+ const tokenData = await tokenRes.json();+ if (tokenData.access_token) {+ connectorInfo[type].hasToken = true;}}+ } catch {+ // Token check failed}} catch {// Status check failed}- }- }+ }),+ );setCloudConnectors(connectorInfo);}