Skip to content

Commit 26d0efd

Browse files
[supervisor] Avoid await in loading frame
/werft with-clean-slate-deployment
1 parent b5a0061 commit 26d0efd

File tree

1 file changed

+16
-7
lines changed
  • components/supervisor/frontend/src

1 file changed

+16
-7
lines changed

components/supervisor/frontend/src/index.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,21 @@ const toStop = new DisposableCollection();
101101
window.addEventListener('message', hideDesktopIdeEventListener, false);
102102
toStop.push({ dispose: () => window.removeEventListener('message', hideDesktopIdeEventListener) });
103103

104+
let isDesktopIde: undefined | boolean = undefined;
105+
let ideStatus: undefined | { desktop: { link: string, label: string } } = undefined;
106+
104107
//#region current-frame
105108
let current: HTMLElement = loading.frame;
106109
let stopped = false;
107-
const nextFrame = async () => {
110+
const nextFrame = () => {
108111
const instance = gitpodServiceClient.info.latestInstance;
109112
if (instance) {
110113
if (instance.status.phase === 'running') {
111114
if (!hideDesktopIde) {
112-
const ideStatus = await supervisorServiceClient.ideReady;
113-
const isDesktopIde = ideStatus && ideStatus.desktop && ideStatus.desktop.link;
114-
if (isDesktopIde) {
115+
if (isDesktopIde == undefined) {
116+
return loading.frame;
117+
}
118+
if (isDesktopIde && !!ideStatus) {
115119
loading.setState({
116120
desktopIdeLink: ideStatus.desktop.link,
117121
desktopIdeLabel: ideStatus.desktop.label || "Open Desktop IDE"
@@ -140,8 +144,8 @@ const toStop = new DisposableCollection();
140144
}
141145
return loading.frame;
142146
}
143-
const updateCurrentFrame = async () => {
144-
const newCurrent = await nextFrame();
147+
const updateCurrentFrame = () => {
148+
const newCurrent = nextFrame();
145149
if (current === newCurrent) {
146150
return;
147151
}
@@ -184,7 +188,7 @@ const toStop = new DisposableCollection();
184188
trackStatusRenderedEvent(`ide-${ideService.state}`, error);
185189
}
186190

187-
await updateCurrentFrame();
191+
updateCurrentFrame();
188192
updateLoadingState();
189193
trackIDEStatusRenderedEvent();
190194
gitpodServiceClient.onDidChangeInfo(() => updateCurrentFrame());
@@ -193,6 +197,11 @@ const toStop = new DisposableCollection();
193197
updateCurrentFrame();
194198
trackIDEStatusRenderedEvent();
195199
});
200+
supervisorServiceClient.ideReady.then(newIdeStatus => {
201+
ideStatus = newIdeStatus;
202+
isDesktopIde = !!ideStatus && !!ideStatus.desktop && !!ideStatus.desktop.link;
203+
updateCurrentFrame();
204+
}).catch(error => console.error(`Unexpected error from supervisorServiceClient.ideReady: ${error}`));
196205
window.addEventListener('unload', () => trackStatusRenderedEvent('window-unload'), { capture: true });
197206
//#endregion
198207

0 commit comments

Comments
 (0)