Skip to content

[dashboard] Make Start page re-fetch workspace info after a connection drop #3862

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
Apr 9, 2021
Merged
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
29 changes: 21 additions & 8 deletions components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
this.setState({ startedInstanceId: result.instanceID });
// Explicitly query state to guarantee we get at least one update
// (needed for already started workspaces, and not hanging in 'Starting ...' for too long)
getGitpodService().server.getWorkspace(workspaceId).then(ws => {
if (ws.latestInstance) {
this.setState({
workspace: ws.workspace
});
this.onInstanceUpdate(ws.latestInstance);
}
});
this.fetchWorkspaceInfo();
} catch (error) {
console.error(error);
if (typeof error === 'string') {
Expand All @@ -106,6 +99,26 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
}
}

async fetchWorkspaceInfo() {
const { workspaceId } = this.props;
try {
const info = await getGitpodService().server.getWorkspace(workspaceId);
if (info.latestInstance) {
this.setState({
workspace: info.workspace
});
this.onInstanceUpdate(info.latestInstance);
}
} catch (error) {
console.error(error);
this.setState({ error });
}
}

notifyDidOpenConnection() {
this.fetchWorkspaceInfo();
}

async onInstanceUpdate(workspaceInstance: WorkspaceInstance) {
const startedInstanceId = this.state?.startedInstanceId;
if (workspaceInstance.workspaceId !== this.props.workspaceId || startedInstanceId !== workspaceInstance.id) {
Expand Down