Skip to content

Commit 76945f1

Browse files
committed
register
1 parent 3a7ddd7 commit 76945f1

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

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

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -324,23 +324,24 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
324324
private async listenForPrebuildUpdates() {
325325
// 'registering for prebuild updates for all projects this user has access to
326326
const projects = await this.getAccessibleProjects();
327-
for (const projectId of projects) {
328-
this.disposables.push(
329-
this.localMessageBroker.listenForPrebuildUpdates(
330-
projectId,
331-
(ctx: TraceContext, update: PrebuildWithStatus) =>
332-
TraceContext.withSpan(
333-
"forwardPrebuildUpdateToClient",
334-
(ctx) => {
335-
traceClientMetadata(ctx, this.clientMetadata);
336-
TraceContext.setJsonRPCMetadata(ctx, "onPrebuildUpdate");
337-
338-
this.client?.onPrebuildUpdate(update);
339-
},
340-
ctx,
341-
),
342-
),
327+
328+
const handler = (ctx: TraceContext, update: PrebuildWithStatus) =>
329+
TraceContext.withSpan(
330+
"forwardPrebuildUpdateToClient",
331+
(ctx) => {
332+
traceClientMetadata(ctx, this.clientMetadata);
333+
TraceContext.setJsonRPCMetadata(ctx, "onPrebuildUpdate");
334+
335+
this.client?.onPrebuildUpdate(update);
336+
},
337+
ctx,
343338
);
339+
340+
for (const projectId of projects) {
341+
this.disposables.pushAll([
342+
this.localMessageBroker.listenForPrebuildUpdates(projectId, handler),
343+
this.subscriber.listenForPrebuildUpdates(projectId, handler),
344+
]);
344345
}
345346

346347
// TODO(at) we need to keep the list of accessible project up to date
@@ -3088,22 +3089,21 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
30883089

30893090
const project = await this.projectsService.createProject(params, user);
30903091
// update client registration for the logged in user
3091-
this.disposables.push(
3092-
this.localMessageBroker.listenForPrebuildUpdates(
3093-
project.id,
3094-
(ctx: TraceContext, update: PrebuildWithStatus) =>
3095-
TraceContext.withSpan(
3096-
"forwardPrebuildUpdateToClient",
3097-
(ctx) => {
3098-
traceClientMetadata(ctx, this.clientMetadata);
3099-
TraceContext.setJsonRPCMetadata(ctx, "onPrebuildUpdate");
3100-
3101-
this.client?.onPrebuildUpdate(update);
3102-
},
3103-
ctx,
3104-
),
3105-
),
3106-
);
3092+
const prebuildUpdateHandler = (ctx: TraceContext, update: PrebuildWithStatus) =>
3093+
TraceContext.withSpan(
3094+
"forwardPrebuildUpdateToClient",
3095+
(ctx) => {
3096+
traceClientMetadata(ctx, this.clientMetadata);
3097+
TraceContext.setJsonRPCMetadata(ctx, "onPrebuildUpdate");
3098+
3099+
this.client?.onPrebuildUpdate(update);
3100+
},
3101+
ctx,
3102+
);
3103+
this.disposables.pushAll([
3104+
this.localMessageBroker.listenForPrebuildUpdates(project.id, prebuildUpdateHandler),
3105+
this.subscriber.listenForPrebuildUpdates(project.id, prebuildUpdateHandler),
3106+
]);
31073107

31083108
return project;
31093109
}

0 commit comments

Comments
 (0)