Skip to content

Commit 1a09166

Browse files
committed
Add polling for outdated
1 parent 9cd386e commit 1a09166

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

site/src/xServices/workspace/workspaceXService.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface WorkspaceContext {
1414
jobError?: Error | unknown
1515
// error creating a new WorkspaceBuild
1616
buildError?: Error | unknown
17-
// these are separate from get X errors because they don't make the page unusable
17+
// these are separate from getX errors because they don't make the page unusable
1818
refreshWorkspaceError: Error | unknown
1919
refreshTemplateError: Error | unknown
2020
}
@@ -82,6 +82,26 @@ export const workspaceMachine = createMachine(
8282
ready: {
8383
type: "parallel",
8484
states: {
85+
// We poll the workspace consistently to know if it becomes outdated
86+
pollingWorkspace: {
87+
initial: "refreshingWorkspace",
88+
states: {
89+
refreshingWorkspace: {
90+
entry: "clearRefreshWorkspaceError",
91+
invoke: {
92+
id: "refreshWorkspace",
93+
src: "refreshWorkspace",
94+
onDone: { actions: "assignWorkspace"},
95+
onError: { target: "waiting", actions: "assignRefreshWorkspaceError" },
96+
},
97+
},
98+
waiting: {
99+
after: {
100+
5000: "refreshingWorkspace"
101+
}
102+
}
103+
}
104+
},
85105
breadcrumb: {
86106
initial: "gettingTemplate",
87107
states: {

0 commit comments

Comments
 (0)