diff --git a/site/src/api/api.ts b/site/src/api/api.ts index 85a9860bc57c5..206e6e5f466f2 100644 --- a/site/src/api/api.ts +++ b/site/src/api/api.ts @@ -2453,21 +2453,11 @@ class ApiMethods { const params = new URLSearchParams( labels?.map((label) => ["label", label]), ); - - try { - const res = - await this.axios.get( - `/api/v2/workspaceagents/${agentId}/containers?${params.toString()}`, - ); - return res.data; - } catch (err) { - // If the error is a 403, it means that experimental - // containers are not enabled on the agent. - if (isAxiosError(err) && err.response?.status === 403) { - return { containers: [] }; - } - throw err; - } + const res = + await this.axios.get( + `/api/v2/workspaceagents/${agentId}/containers?${params.toString()}`, + ); + return res.data; }; getInboxNotifications = async (startingBeforeId?: string) => { diff --git a/site/src/modules/resources/AgentRow.tsx b/site/src/modules/resources/AgentRow.tsx index c4d104501fd67..bc0751c332942 100644 --- a/site/src/modules/resources/AgentRow.tsx +++ b/site/src/modules/resources/AgentRow.tsx @@ -10,6 +10,7 @@ import type { WorkspaceAgent, WorkspaceAgentMetadata, } from "api/typesGenerated"; +import { isAxiosError } from "axios"; import { DropdownArrow } from "components/DropdownArrow/DropdownArrow"; import type { Line } from "components/Logs/LogLine"; import { Stack } from "components/Stack/Stack"; @@ -160,7 +161,12 @@ export const AgentRow: FC = ({ select: (res) => res.containers.filter((c) => c.status === "running"), // TODO: Implement a websocket connection to get updates on containers // without having to poll. - refetchInterval: 10_000, + refetchInterval: (_, query) => { + const { error } = query.state; + return isAxiosError(error) && error.response?.status === 403 + ? false + : 10_000; + }, }); return (