From 75b1576278d01dabd3326d12241af1c5ea6a989a Mon Sep 17 00:00:00 2001 From: Huiwen Date: Wed, 8 Nov 2023 12:55:47 +0000 Subject: [PATCH] Update usage of func --- .../src/service/json-rpc-workspace-client.ts | 20 ++++++++++++------- .../server/src/workspace/workspace-service.ts | 18 ++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/components/dashboard/src/service/json-rpc-workspace-client.ts b/components/dashboard/src/service/json-rpc-workspace-client.ts index 5e22cdf0902473..d743d0d3b4dec3 100644 --- a/components/dashboard/src/service/json-rpc-workspace-client.ts +++ b/components/dashboard/src/service/json-rpc-workspace-client.ts @@ -38,13 +38,19 @@ export class JsonRpcWorkspaceClient implements PromiseClient( - (sink) => { - const dispose = getGitpodService().registerClient({ - onInstanceUpdate: (instance) => { - sink.next(instance); - }, - }); - return dispose.dispose; + (queue) => { + try { + const dispose = getGitpodService().registerClient({ + onInstanceUpdate: (instance) => { + queue.push(instance); + }, + }); + return () => { + dispose.dispose(); + }; + } catch (e) { + queue.fail(e); + } }, { signal: options.signal }, ); diff --git a/components/server/src/workspace/workspace-service.ts b/components/server/src/workspace/workspace-service.ts index 5e88042152d10d..b452558dbd498a 100644 --- a/components/server/src/workspace/workspace-service.ts +++ b/components/server/src/workspace/workspace-service.ts @@ -736,13 +736,17 @@ export class WorkspaceService { public watchWorkspaceStatus(userId: string, opts: { signal: AbortSignal }) { return generateAsyncGenerator((sink) => { - const dispose = this.subscriber.listenForWorkspaceInstanceUpdates(userId, (_ctx, instance) => { - sink.next(instance); - }); - return () => { - console.log("=============dispose"); - dispose.dispose(); - }; + try { + const dispose = this.subscriber.listenForWorkspaceInstanceUpdates(userId, (_ctx, instance) => { + sink.push(instance); + }); + return () => { + console.log("=============dispose"); + dispose.dispose(); + }; + } catch (e) { + sink.fail(e); + } }, opts); }