Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee2aeb4

Browse files
fix: avoid pulling containers when it is not enabled (#17855)
We've been continuously pulling the containers endpoint even when theagent does not support containers. To optimize the requests, we cancheck if it is throwing an error and stop if it is a 403 status code.
1 parentc42a315 commitee2aeb4

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
constparams=newURLSearchParams(
24542454
labels?.map((label)=>["label",label]),
24552455
);
2456-
2457-
try{
2458-
constres=
2459-
awaitthis.axios.get<TypesGen.WorkspaceAgentListContainersResponse>(
2460-
`/api/v2/workspaceagents/${agentId}/containers?${params.toString()}`,
2461-
);
2462-
returnres.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-
throwerr;
2470-
}
2456+
constres=
2457+
awaitthis.axios.get<TypesGen.WorkspaceAgentListContainersResponse>(
2458+
`/api/v2/workspaceagents/${agentId}/containers?${params.toString()}`,
2459+
);
2460+
returnres.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
@@ -10,6 +10,7 @@ import type {
1010
WorkspaceAgent,
1111
WorkspaceAgentMetadata,
1212
}from"api/typesGenerated";
13+
import{isAxiosError}from"axios";
1314
import{DropdownArrow}from"components/DropdownArrow/DropdownArrow";
1415
importtype{Line}from"components/Logs/LogLine";
1516
import{Stack}from"components/Stack/Stack";
@@ -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+
returnisAxiosError(error)&&error.response?.status===403
167+
?false
168+
:10_000;
169+
},
164170
});
165171

166172
return(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp