Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const MockProvisionerJob: TypesGen.ProvisionerJob = {
id: "test-provisioner-job",
status: "succeeded",
storage_source: "asdf",
completed_at: "2022-05-17T17:39:01.382927298Z",
}

export const MockFailedProvisionerJob: TypesGen.ProvisionerJob = {
Expand Down
11 changes: 6 additions & 5 deletions site/src/xServices/workspace/workspaceXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,12 +550,13 @@ export const workspaceMachine = createMachine(
}
},
getResources: async (context) => {
if (context.workspace) {
const resources = await API.getWorkspaceResources(context.workspace.latest_build.id)
return resources
} else {
throw Error("Cannot fetch workspace resources without workspace")
// If the job hasn't completed, fetching resources will result
// in an unfriendly error for the user.
if (!context.workspace?.latest_build.job.completed_at) {
return []
}
const resources = await API.getWorkspaceResources(context.workspace.latest_build.id)
return resources
},
getBuilds: async (context) => {
if (context.workspace) {
Expand Down