Skip to content

Commit ced21ef

Browse files
committed
retry
1 parent 7ac491b commit ced21ef

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

components/dashboard/src/start/StartWorkspace.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,29 @@ function ImageBuildView(props: ImageBuildViewProps) {
418418
const logsEmitter = new EventEmitter();
419419

420420
useEffect(() => {
421-
const watchBuild = () => getGitpodService().server.watchWorkspaceImageBuildLogs(props.workspaceId);
421+
let registered = false;
422+
const watchBuild = () => {
423+
if (registered) {
424+
return;
425+
}
426+
427+
getGitpodService().server.watchWorkspaceImageBuildLogs(props.workspaceId)
428+
.then(() => registered = true)
429+
.catch(err => {
430+
431+
if (err?.code === ErrorCodes.HEADLESS_LOG_NOT_YET_AVAILABLE) {
432+
// wait, and then retry
433+
setTimeout(watchBuild, 5000);
434+
}
435+
})
436+
}
422437
watchBuild();
423438

424439
const toDispose = getGitpodService().registerClient({
425-
notifyDidOpenConnection: () => watchBuild(),
440+
notifyDidOpenConnection: () => {
441+
registered = false; // new connection, we're not registered anymore
442+
watchBuild();
443+
},
426444
onWorkspaceImageBuildLogs: (info: WorkspaceImageBuild.StateInfo, content?: WorkspaceImageBuild.LogContent) => {
427445
if (!content) {
428446
return;

components/gitpod-protocol/src/messaging/error.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,7 @@ export namespace ErrorCodes {
7878

7979
// 630 Snapshot Error
8080
export const SNAPSHOT_ERROR = 630;
81+
82+
// 640 Headless logs are not available (yet)
83+
export const HEADLESS_LOG_NOT_YET_AVAILABLE = 640;
8184
}

components/server/src/workspace/gitpod-server-impl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
11841184
}, aborted);
11851185
} catch (err) {
11861186
log.error(logCtx, "cannot watch imagebuild logs for workspaceId", err);
1187+
throw new ResponseError(ErrorCodes.HEADLESS_LOG_NOT_YET_AVAILABLE, "cannot watch imagebuild logs for workspaceId");
11871188
} finally {
11881189
aborted.resolve(false);
11891190
}

0 commit comments

Comments
 (0)