Skip to content

Commit fde1fb4

Browse files
committed
fix: Don't fetch resources when a workspace is building
Fixes #3423.
1 parent c0cc8b9 commit fde1fb4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

site/src/xServices/workspace/workspaceXService.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,13 @@ export const workspaceMachine = createMachine(
550550
}
551551
},
552552
getResources: async (context) => {
553-
if (context.workspace) {
554-
const resources = await API.getWorkspaceResources(context.workspace.latest_build.id)
555-
return resources
556-
} else {
557-
throw Error("Cannot fetch workspace resources without workspace")
553+
// If the job hasn't completed, fetching resources will result
554+
// in an unfriendly error for the user.
555+
if (!context.workspace?.latest_build.job.completed_at) {
556+
return []
558557
}
558+
const resources = await API.getWorkspaceResources(context.workspace.latest_build.id)
559+
return resources
559560
},
560561
getBuilds: async (context) => {
561562
if (context.workspace) {

0 commit comments

Comments
 (0)