@@ -21,6 +21,7 @@ import { inject, injectable } from "inversify";
21
21
import { EntitlementService , HitParallelWorkspaceLimit , MayStartWorkspaceResult } from "./entitlement-service" ;
22
22
import { CostCenter_BillingStrategy } from "@gitpod/usage-api/lib/usage/v1/usage.pb" ;
23
23
import { UsageService } from "../orgs/usage-service" ;
24
+ import { log } from "@gitpod/gitpod-protocol/lib/util/logging" ;
24
25
25
26
const MAX_PARALLEL_WORKSPACES_FREE = 4 ;
26
27
const MAX_PARALLEL_WORKSPACES_PAID = 16 ;
@@ -110,10 +111,17 @@ export class EntitlementServiceUBP implements EntitlementService {
110
111
111
112
private async hasPaidSubscription ( userId : string , organizationId ?: string ) : Promise < boolean > {
112
113
if ( organizationId ) {
113
- // This is the "stricter", more correct version: We only allow privileges on the Organization that is paying for it
114
- const { billingStrategy } = await this . usageService . getCostCenter ( userId , organizationId ) ;
115
- return billingStrategy === CostCenter_BillingStrategy . BILLING_STRATEGY_STRIPE ;
114
+ try {
115
+ // This is the "stricter", more correct version: We only allow privileges on the Organization that is paying for it
116
+ const { billingStrategy } = await this . usageService . getCostCenter ( userId , organizationId ) ;
117
+ return billingStrategy === CostCenter_BillingStrategy . BILLING_STRATEGY_STRIPE ;
118
+ } catch ( err ) {
119
+ log . warn ( { userId, organizationId } , "Error checking if user is subscribed to organization" , err ) ;
120
+ return false ;
121
+ }
116
122
}
123
+
124
+ // TODO(gpl) Remove everything below once organizations are fully rolled out
117
125
// This is the old behavior, stemming from our transition to PAYF, where our API did-/doesn't pass organizationId, yet
118
126
// Member of paid team?
119
127
const teams = await this . teamDB . findTeamsByUser ( userId ) ;
@@ -126,8 +134,13 @@ export class EntitlementServiceUBP implements EntitlementService {
126
134
return new Promise ( ( resolve , reject ) => {
127
135
// If any promise returns true, immediately resolve with true
128
136
isTeamSubscribedPromises . forEach ( async ( isTeamSubscribedPromise : Promise < boolean > ) => {
129
- const isTeamSubscribed = await isTeamSubscribedPromise ;
130
- if ( isTeamSubscribed ) resolve ( true ) ;
137
+ try {
138
+ const isTeamSubscribed = await isTeamSubscribedPromise ;
139
+ if ( isTeamSubscribed ) resolve ( true ) ;
140
+ } catch ( err ) {
141
+ log . warn ( { userId, organizationId } , "Error checking if user is subscribed to organization" , err ) ;
142
+ resolve ( false ) ;
143
+ }
131
144
} ) ;
132
145
133
146
// If neither of the above fires, resolve with false
0 commit comments