@@ -96,7 +96,6 @@ import { WorkspaceManagerClientProvider } from "@gitpod/ws-manager/lib/client-pr
96
96
import {
97
97
AdmissionLevel ,
98
98
ControlAdmissionRequest ,
99
- MarkActiveRequest ,
100
99
StopWorkspacePolicy ,
101
100
TakeSnapshotRequest ,
102
101
} from "@gitpod/ws-manager/lib/core_pb" ;
@@ -173,7 +172,7 @@ import { RedisSubscriber } from "../messaging/redis-subscriber";
173
172
import { UsageService } from "../orgs/usage-service" ;
174
173
import { UserService } from "../user/user-service" ;
175
174
import { SSHKeyService } from "../user/sshkey-service" ;
176
- import { StartWorkspaceOptions , WorkspaceService , mapGrpcError } from "./workspace-service" ;
175
+ import { StartWorkspaceOptions , WorkspaceService } from "./workspace-service" ;
177
176
import { GitpodTokenService } from "../user/gitpod-token-service" ;
178
177
import { EnvVarService } from "../user/env-var-service" ;
179
178
@@ -1098,36 +1097,9 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
1098
1097
1099
1098
const user = await this . checkAndBlockUser ( "sendHeartBeat" , undefined , { instanceId } ) ;
1100
1099
1101
- try {
1102
- const wsi = await this . workspaceDb . trace ( ctx ) . findInstanceById ( instanceId ) ;
1103
- if ( ! wsi ) {
1104
- throw new ApplicationError ( ErrorCodes . NOT_FOUND , "workspace does not exist" ) ;
1105
- }
1106
-
1107
- const ws = await this . workspaceDb . trace ( ctx ) . findById ( wsi . workspaceId ) ;
1108
- if ( ! ws ) {
1109
- throw new ApplicationError ( ErrorCodes . NOT_FOUND , "workspace does not exist" ) ;
1110
- }
1111
- await this . guardAccess ( { kind : "workspaceInstance" , subject : wsi , workspace : ws } , "update" ) ;
1112
-
1113
- const wasClosed = ! ! ( options && options . wasClosed ) ;
1114
- await this . workspaceDb . trace ( ctx ) . updateLastHeartbeat ( instanceId , user . id , new Date ( ) , wasClosed ) ;
1115
-
1116
- const req = new MarkActiveRequest ( ) ;
1117
- req . setId ( instanceId ) ;
1118
- req . setClosed ( wasClosed ) ;
1119
-
1120
- const client = await this . workspaceManagerClientProvider . get ( wsi . region ) ;
1121
- await client . markActive ( ctx , req ) ;
1122
- } catch ( e ) {
1123
- if ( e . message && typeof e . message === "string" && ( e . message as String ) . endsWith ( "does not exist" ) ) {
1124
- // This is an old tab with open workspace: drop silently
1125
- return ;
1126
- } else {
1127
- e = mapGrpcError ( e ) ;
1128
- throw e ;
1129
- }
1130
- }
1100
+ await this . workspaceService . sendHeartBeat ( user . id , options , ( instance , workspace ) =>
1101
+ this . guardAccess ( { kind : "workspaceInstance" , subject : instance , workspace } , "update" ) ,
1102
+ ) ;
1131
1103
}
1132
1104
1133
1105
async getWorkspaceOwner ( ctx : TraceContext , workspaceId : string ) : Promise < UserInfo | undefined > {
0 commit comments