Skip to content

fix: Don't fetch resources when a workspace is building #3424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2022
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