From 09a9457021c2baac37c5ce73b9429269c183eaa2 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 17 Feb 2026 21:23:35 -0800 Subject: [PATCH 1/6] Fix transaction issue --- server/lib/billing/usageService.ts | 16 ++++++++-------- server/routers/gerbil/receiveBandwidth.ts | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/server/lib/billing/usageService.ts b/server/lib/billing/usageService.ts index a7786c76..d7299284 100644 --- a/server/lib/billing/usageService.ts +++ b/server/lib/billing/usageService.ts @@ -46,8 +46,6 @@ export class UsageService { return null; } - let orgIdToUse = await this.getBillingOrg(orgId, transaction); - // Truncate value to 11 decimal places value = this.truncateValue(value); @@ -59,6 +57,7 @@ export class UsageService { try { let usage; if (transaction) { + const orgIdToUse = await this.getBillingOrg(orgId, transaction); usage = await this.internalAddUsage( orgIdToUse, featureId, @@ -67,6 +66,7 @@ export class UsageService { ); } else { await db.transaction(async (trx) => { + const orgIdToUse = await this.getBillingOrg(orgId, trx); usage = await this.internalAddUsage( orgIdToUse, featureId, @@ -92,7 +92,7 @@ export class UsageService { const delay = baseDelay + jitter; logger.warn( - `Deadlock detected for ${orgIdToUse}/${featureId}, retrying attempt ${attempt}/${maxRetries} after ${delay.toFixed(0)}ms` + `Deadlock detected for ${orgId}/${featureId}, retrying attempt ${attempt}/${maxRetries} after ${delay.toFixed(0)}ms` ); await new Promise((resolve) => setTimeout(resolve, delay)); @@ -100,7 +100,7 @@ export class UsageService { } logger.error( - `Failed to add usage for ${orgIdToUse}/${featureId} after ${attempt} attempts:`, + `Failed to add usage for ${orgId}/${featureId} after ${attempt} attempts:`, error ); break; @@ -169,7 +169,7 @@ export class UsageService { return; } - let orgIdToUse = await this.getBillingOrg(orgId); + const orgIdToUse = await this.getBillingOrg(orgId); try { // Truncate value to 11 decimal places if provided @@ -227,7 +227,7 @@ export class UsageService { orgId: string, featureId: FeatureId ): Promise { - let orgIdToUse = await this.getBillingOrg(orgId); + const orgIdToUse = await this.getBillingOrg(orgId); const cacheKey = `customer_${orgIdToUse}_${featureId}`; const cached = cache.get(cacheKey); @@ -274,7 +274,7 @@ export class UsageService { return null; } - let orgIdToUse = await this.getBillingOrg(orgId, trx); + const orgIdToUse = await this.getBillingOrg(orgId, trx); const usageId = `${orgIdToUse}-${featureId}`; @@ -382,7 +382,7 @@ export class UsageService { return false; } - let orgIdToUse = await this.getBillingOrg(orgId, trx); + const orgIdToUse = await this.getBillingOrg(orgId, trx); // This method should check the current usage against the limits set for the organization // and kick out all of the sites on the org diff --git a/server/routers/gerbil/receiveBandwidth.ts b/server/routers/gerbil/receiveBandwidth.ts index 937fa271..dbd687a1 100644 --- a/server/routers/gerbil/receiveBandwidth.ts +++ b/server/routers/gerbil/receiveBandwidth.ts @@ -197,7 +197,6 @@ export async function updateSiteBandwidth( usageService .checkLimitSet( orgId, - FeatureId.EGRESS_DATA_MB, bandwidthUsage ) From 5987f6b2cdddca98bdeec3e633a2b8de3ccb6e8e Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 17 Feb 2026 21:55:57 -0800 Subject: [PATCH 2/6] Allow enterprise --- server/private/lib/billing/getOrgTierData.ts | 3 ++- src/lib/api/isOrgSubscribed.ts | 2 +- src/providers/SubscriptionStatusProvider.tsx | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/private/lib/billing/getOrgTierData.ts b/server/private/lib/billing/getOrgTierData.ts index d87f2c38..9972dcfc 100644 --- a/server/private/lib/billing/getOrgTierData.ts +++ b/server/private/lib/billing/getOrgTierData.ts @@ -78,7 +78,8 @@ export async function getOrgTierData( if ( subscription.type === "tier1" || subscription.type === "tier2" || - subscription.type === "tier3" + subscription.type === "tier3" || + subscription.type === "enterprise" ) { tier = subscription.type; active = true; diff --git a/src/lib/api/isOrgSubscribed.ts b/src/lib/api/isOrgSubscribed.ts index b57810cb..ce19b917 100644 --- a/src/lib/api/isOrgSubscribed.ts +++ b/src/lib/api/isOrgSubscribed.ts @@ -20,7 +20,7 @@ export const isOrgSubscribed = cache(async (orgId: string) => { try { const subRes = await getCachedSubscription(orgId); subscribed = - (subRes.data.data.tier == "tier1" || subRes.data.data.tier == "tier2" || subRes.data.data.tier == "tier3") && + (subRes.data.data.tier == "tier1" || subRes.data.data.tier == "tier2" || subRes.data.data.tier == "tier3" || subRes.data.data.tier == "enterprise") && subRes.data.data.active; } catch {} } diff --git a/src/providers/SubscriptionStatusProvider.tsx b/src/providers/SubscriptionStatusProvider.tsx index 27e90fff..a105e5d5 100644 --- a/src/providers/SubscriptionStatusProvider.tsx +++ b/src/providers/SubscriptionStatusProvider.tsx @@ -42,7 +42,8 @@ export function SubscriptionStatusProvider({ if ( subscription.type == "tier1" || subscription.type == "tier2" || - subscription.type == "tier3" + subscription.type == "tier3" || + subscription.type == "enterprise" ) { return { tier: subscription.type, @@ -61,7 +62,7 @@ export function SubscriptionStatusProvider({ const isSubscribed = () => { const { tier, active } = getTier(); return ( - (tier == "tier1" || tier == "tier2" || tier == "tier3") && + (tier == "tier1" || tier == "tier2" || tier == "tier3" || tier == "enterprise") && active ); }; From eedf57af8973404d002d00b77e9fea0e3540d9f8 Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Thu, 19 Feb 2026 17:54:40 -0800 Subject: [PATCH 3/6] disable rybbit in saas --- src/app/layout.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 0844eb62..706c9a9c 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -82,13 +82,13 @@ export default async function RootLayout({ - {build === "saas" && ( + {/* build === "saas" && (