mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: Don't fetch resources when a workspace is building (#3424)
Fixes #3423.
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user