diff --git a/ui/src/app/workflows/components/workflow-details/workflow-details.tsx b/ui/src/app/workflows/components/workflow-details/workflow-details.tsx index 9bae27258002..1fe4e5ec7b65 100644 --- a/ui/src/app/workflows/components/workflow-details/workflow-details.tsx +++ b/ui/src/app/workflows/components/workflow-details/workflow-details.tsx @@ -384,33 +384,30 @@ export function WorkflowDetails({history, location, match}: RouteComponentProps< // Get workflow useEffect(() => { (async () => { - let archivedWf: Workflow; - if (uid !== '') { - try { - archivedWf = await services.workflows.getArchived(namespace, uid); - setError(null); - } catch (err) { - if (err.status !== 404) { - setError(err); - } - } - } - try { const wf = await services.workflows.get(namespace, name); + setUid(wf.metadata.uid); + setWorkflow(wf); setError(null); - // If we find live workflow which has same uid, we use live workflow. - if (!archivedWf || archivedWf.metadata.uid === wf.metadata.uid) { - setWorkflow(wf); - setUid(wf.metadata.uid); - } else { - setWorkflow(archivedWf); - } + return; } catch (err) { - if (archivedWf) { - setWorkflow(archivedWf); - } else { + if (err.status !== 404 && uid === '') { setError(err); + return; + } + + try { + const archivedWf = await services.workflows.getArchived(namespace, uid); + setWorkflow(archivedWf); + setError(null); + return; + } catch (archiveErr) { + if (archiveErr.status === 500 && archiveErr.response.body.message === 'getting archived workflows not supported') { + setError(err); + return; + } + + setError(archiveErr); } } })();