@@ -247,6 +247,7 @@ export async function POST(
247247 }
248248
249249 // --- PHASE 3: Rate limiting for webhook execution ---
250+ let isEnterprise = false
250251 try {
251252 // Get user subscription for rate limiting
252253 const [ subscriptionRecord ] = await db
@@ -256,6 +257,7 @@ export async function POST(
256257 . limit ( 1 )
257258
258259 const subscriptionPlan = ( subscriptionRecord ?. plan || 'free' ) as SubscriptionPlan
260+ isEnterprise = subscriptionPlan === 'enterprise'
259261
260262 // Check async rate limits (webhooks are processed asynchronously)
261263 const rateLimiter = new RateLimiter ( )
@@ -333,7 +335,7 @@ export async function POST(
333335 // Continue processing - better to risk usage limit bypass than fail webhook
334336 }
335337
336- // --- PHASE 5: Queue webhook execution (trigger.dev or direct based on env) ---
338+ // --- PHASE 5: Queue webhook execution (trigger.dev or direct based on plan/ env) ---
337339 try {
338340 const payload = {
339341 webhookId : foundWebhook . id ,
@@ -346,7 +348,9 @@ export async function POST(
346348 blockId : foundWebhook . blockId ,
347349 }
348350
349- const useTrigger = isTruthy ( env . TRIGGER_DEV_ENABLED )
351+ // Enterprise users always execute directly, others check TRIGGER_DEV_ENABLED env
352+ // Note: isEnterprise was already determined during rate limiting phase
353+ const useTrigger = ! isEnterprise && isTruthy ( env . TRIGGER_DEV_ENABLED )
350354
351355 if ( useTrigger ) {
352356 const handle = await tasks . trigger ( 'webhook-execution' , payload )
@@ -358,8 +362,9 @@ export async function POST(
358362 void executeWebhookJob ( payload ) . catch ( ( error ) => {
359363 logger . error ( `[${ requestId } ] Direct webhook execution failed` , error )
360364 } )
365+ const reason = isEnterprise ? 'Enterprise plan' : 'Trigger.dev disabled'
361366 logger . info (
362- `[${ requestId } ] Queued direct webhook execution for ${ foundWebhook . provider } webhook (Trigger.dev disabled )`
367+ `[${ requestId } ] Queued direct webhook execution for ${ foundWebhook . provider } webhook (${ reason } )`
363368 )
364369 }
365370
0 commit comments