Skip to content

Commit 7d9986f

Browse files
[Dashboard] fix: handle unreachable engine instances (#6006)
1 parent bb6c71e commit 7d9986f

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(instance)/[engineId]/layout.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,15 @@ function EngineInstanceLayoutContent(props: {
8989
);
9090
}
9191

92-
if (permission.status === 401 || permission.status === 500) {
92+
if (permission.status === 500) {
93+
return (
94+
<EngineErrorPage rootPath={rootPath}>
95+
<p> Engine Instance Could Not Be Reached </p>
96+
</EngineErrorPage>
97+
);
98+
}
99+
100+
if (permission.status === 401) {
93101
return (
94102
<EngineErrorPage rootPath={rootPath}>
95103
<div>

apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/_utils/getEngineAccessPermission.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@ export async function getEngineAccessPermission(params: {
22
authToken: string;
33
instanceUrl: string;
44
}) {
5-
const res = await fetch(`${params.instanceUrl}auth/permissions/get-all`, {
6-
method: "GET",
7-
headers: {
8-
"Content-Type": "application/json",
9-
Authorization: `Bearer ${params.authToken}`,
10-
},
11-
});
5+
try {
6+
const res = await fetch(`${params.instanceUrl}auth/permissions/get-all`, {
7+
method: "GET",
8+
headers: {
9+
"Content-Type": "application/json",
10+
Authorization: `Bearer ${params.authToken}`,
11+
},
12+
});
1213

13-
return {
14-
ok: res.ok, // has access if this is true
15-
status: res.status,
16-
};
14+
return {
15+
ok: res.ok, // has access if this is true
16+
status: res.status,
17+
};
18+
} catch {
19+
return {
20+
ok: false,
21+
status: 500,
22+
};
23+
}
1724
}

0 commit comments

Comments
 (0)