-
Notifications
You must be signed in to change notification settings - Fork 136
Fix stale certificate issued state #575
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,7 @@ import { | |||||||||
| import useFetchApi from "@utils/api"; | ||||||||||
| import Badge from "@components/Badge"; | ||||||||||
| import { Loader2 } from "lucide-react"; | ||||||||||
| import { useMemo } from "react"; | ||||||||||
| import { useRef } from "react"; | ||||||||||
|
|
||||||||||
| type Props = { | ||||||||||
| serviceId: string; | ||||||||||
|
|
@@ -21,38 +21,33 @@ export default function ReverseProxyStatusCell({ | |||||||||
| meta, | ||||||||||
| enabled, | ||||||||||
| }: Readonly<Props>) { | ||||||||||
| const status = meta?.status; | ||||||||||
| const certificateIssued = !!meta?.certificate_issued_at; | ||||||||||
| const dataRef = useRef<ReverseProxy | undefined>(undefined); | ||||||||||
|
|
||||||||||
| const isSettingUp = | ||||||||||
| enabled && | ||||||||||
| status !== undefined && | ||||||||||
| status !== ReverseProxyStatus.ACTIVE && | ||||||||||
| !certificateIssued; | ||||||||||
| const isActive = | ||||||||||
| meta?.status === ReverseProxyStatus.ACTIVE || | ||||||||||
| dataRef.current?.meta?.status === ReverseProxyStatus.ACTIVE; | ||||||||||
|
|
||||||||||
| const certificateIssued = | ||||||||||
| !!meta?.certificate_issued_at || | ||||||||||
| !!dataRef.current?.meta?.certificate_issued_at; | ||||||||||
|
|
||||||||||
| const shouldPoll = !!enabled && !(isActive && certificateIssued); | ||||||||||
|
|
||||||||||
| const { data } = useFetchApi<ReverseProxy>( | ||||||||||
| `/reverse-proxies/services/${serviceId}`, | ||||||||||
| true, | ||||||||||
| false, | ||||||||||
| isSettingUp, | ||||||||||
| shouldPoll, | ||||||||||
| { refreshInterval: POLL_INTERVAL_MS }, | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| const currentStatus = data?.meta?.status ?? status; | ||||||||||
|
|
||||||||||
| const currentCertificateIssued = useMemo(() => { | ||||||||||
| if (data && data?.meta) return !!data?.meta?.certificate_issued_at; | ||||||||||
| return certificateIssued; | ||||||||||
| }, [data]); | ||||||||||
| dataRef.current = data; | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve last known data instead of overwriting ref with Unconditionally assigning 🔧 Proposed fix- dataRef.current = data;
+ if (data !== undefined) {
+ dataRef.current = data;
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| if ( | ||||||||||
| !enabled || | ||||||||||
| (currentStatus === ReverseProxyStatus.ACTIVE && currentCertificateIssued) | ||||||||||
| ) { | ||||||||||
| if (!enabled || (isActive && certificateIssued)) { | ||||||||||
| return null; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (!currentCertificateIssued) { | ||||||||||
| if (!certificateIssued) { | ||||||||||
| return ( | ||||||||||
| <div className={"flex"}> | ||||||||||
| <Badge variant={"yellow"}> | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use one coherent metadata source for readiness checks
isActiveandcertificateIssuedare currently computed with separate ORs acrossmetaanddataRef.current. That can produce a synthetic(ACTIVE && issued)state from different snapshots, which may stop polling and hide the cell too early.🔧 Proposed fix
Also applies to: 46-46
🤖 Prompt for AI Agents