Skip to content

Commit 986040f

Browse files
committed
fix: avoid pulling containers when it is not enabled
1 parent c42a315 commit 986040f

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

site/src/api/api.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,21 +2453,11 @@ class ApiMethods {
24532453
const params = new URLSearchParams(
24542454
labels?.map((label) => ["label", label]),
24552455
);
2456-
2457-
try {
2458-
const res =
2459-
await this.axios.get<TypesGen.WorkspaceAgentListContainersResponse>(
2460-
`/api/v2/workspaceagents/${agentId}/containers?${params.toString()}`,
2461-
);
2462-
return res.data;
2463-
} catch (err) {
2464-
// If the error is a 403, it means that experimental
2465-
// containers are not enabled on the agent.
2466-
if (isAxiosError(err) && err.response?.status === 403) {
2467-
return { containers: [] };
2468-
}
2469-
throw err;
2470-
}
2456+
const res =
2457+
await this.axios.get<TypesGen.WorkspaceAgentListContainersResponse>(
2458+
`/api/v2/workspaceagents/${agentId}/containers?${params.toString()}`,
2459+
);
2460+
return res.data;
24712461
};
24722462

24732463
getInboxNotifications = async (startingBeforeId?: string) => {

site/src/modules/resources/AgentRow.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { PortForwardButton } from "./PortForwardButton";
4040
import { AgentSSHButton } from "./SSHButton/SSHButton";
4141
import { TerminalLink } from "./TerminalLink/TerminalLink";
4242
import { VSCodeDesktopButton } from "./VSCodeDesktopButton/VSCodeDesktopButton";
43+
import { isAxiosError } from "axios";
4344

4445
export interface AgentRowProps {
4546
agent: WorkspaceAgent;
@@ -160,7 +161,12 @@ export const AgentRow: FC<AgentRowProps> = ({
160161
select: (res) => res.containers.filter((c) => c.status === "running"),
161162
// TODO: Implement a websocket connection to get updates on containers
162163
// without having to poll.
163-
refetchInterval: 10_000,
164+
refetchInterval: (_, query) => {
165+
const { error } = query.state;
166+
return isAxiosError(error) && error.response?.status === 403
167+
? false
168+
: 10_000;
169+
},
164170
});
165171

166172
return (

0 commit comments

Comments
 (0)