Revert "feat(enterprise-plan-webhooks): skip webhook queue for enterprise plan users (#1250)" (#1257)

This reverts commit 37dcde2afc.
This commit is contained in:
Vikhyath Mondreti
2025-09-04 23:37:19 -07:00
committed by GitHub
parent ab71fcfc49
commit 0a86eda853

View File

@@ -248,13 +248,11 @@ export async function POST(
}
// --- PHASE 3: Rate limiting for webhook execution ---
let isEnterprise = false
try {
// Get user subscription for rate limiting (checks both personal and org subscriptions)
const userSubscription = await getHighestPrioritySubscription(foundWorkflow.userId)
const subscriptionPlan = (userSubscription?.plan || 'free') as SubscriptionPlan
isEnterprise = subscriptionPlan === 'enterprise'
const subscriptionPlan = (subscriptionRecord?.plan || 'free') as SubscriptionPlan
// Check async rate limits (webhooks are processed asynchronously)
const rateLimiter = new RateLimiter()
@@ -332,7 +330,7 @@ export async function POST(
// Continue processing - better to risk usage limit bypass than fail webhook
}
// --- PHASE 5: Queue webhook execution (trigger.dev or direct based on plan/env) ---
// --- PHASE 5: Queue webhook execution (trigger.dev or direct based on env) ---
try {
const payload = {
webhookId: foundWebhook.id,
@@ -345,9 +343,7 @@ export async function POST(
blockId: foundWebhook.blockId,
}
// Enterprise users always execute directly, others check TRIGGER_DEV_ENABLED env
// Note: isEnterprise was already determined during rate limiting phase
const useTrigger = !isEnterprise && isTruthy(env.TRIGGER_DEV_ENABLED)
const useTrigger = isTruthy(env.TRIGGER_DEV_ENABLED)
if (useTrigger) {
const handle = await tasks.trigger('webhook-execution', payload)
@@ -359,9 +355,8 @@ export async function POST(
void executeWebhookJob(payload).catch((error) => {
logger.error(`[${requestId}] Direct webhook execution failed`, error)
})
const reason = isEnterprise ? 'Enterprise plan' : 'Trigger.dev disabled'
logger.info(
`[${requestId}] Queued direct webhook execution for ${foundWebhook.provider} webhook (${reason})`
`[${requestId}] Queued direct webhook execution for ${foundWebhook.provider} webhook (Trigger.dev disabled)`
)
}