@@ -5,7 +5,7 @@ import { and, eq, isNull, or } from 'drizzle-orm'
55import { type NextRequest , NextResponse } from 'next/server'
66import { v4 as uuidv4 } from 'uuid'
77import { checkEnterprisePlan , checkTeamPlan } from '@/lib/billing/subscriptions/utils'
8- import { getJobQueue , shouldExecuteInline } from '@/lib/core/async-jobs'
8+ import { getInlineJobQueue , getJobQueue , shouldExecuteInline } from '@/lib/core/async-jobs'
99import { isProd } from '@/lib/core/config/feature-flags'
1010import { safeCompare } from '@/lib/core/security/encryption'
1111import { getEffectiveDecryptedEnv } from '@/lib/environment/utils'
@@ -29,6 +29,7 @@ import {
2929import { executeWebhookJob } from '@/background/webhook-execution'
3030import { resolveEnvVarReferences } from '@/executor/utils/reference-validation'
3131import { isConfluencePayloadMatch } from '@/triggers/confluence/utils'
32+ import { isPollingWebhookProvider } from '@/triggers/constants'
3233import { isGitHubEventMatch } from '@/triggers/github/utils'
3334import { isHubSpotContactEventMatch } from '@/triggers/hubspot/utils'
3435import { isJiraEventMatch } from '@/triggers/jira/utils'
@@ -1116,15 +1117,24 @@ export async function queueWebhookExecution(
11161117 ...( credentialId ? { credentialId } : { } ) ,
11171118 }
11181119
1119- const jobQueue = await getJobQueue ( )
1120- const jobId = await jobQueue . enqueue ( 'webhook-execution' , payload , {
1121- metadata : { workflowId : foundWorkflow . id , userId : actorUserId } ,
1122- } )
1123- logger . info (
1124- `[${ options . requestId } ] Queued webhook execution task ${ jobId } for ${ foundWebhook . provider } webhook`
1125- )
1120+ const isPolling = isPollingWebhookProvider ( payload . provider )
11261121
1127- if ( shouldExecuteInline ( ) ) {
1122+ if ( isPolling && ! shouldExecuteInline ( ) ) {
1123+ const jobQueue = await getJobQueue ( )
1124+ const jobId = await jobQueue . enqueue ( 'webhook-execution' , payload , {
1125+ metadata : { workflowId : foundWorkflow . id , userId : actorUserId } ,
1126+ } )
1127+ logger . info (
1128+ `[${ options . requestId } ] Queued polling webhook execution task ${ jobId } for ${ foundWebhook . provider } webhook via job queue`
1129+ )
1130+ } else {
1131+ const jobQueue = await getInlineJobQueue ( )
1132+ const jobId = await jobQueue . enqueue ( 'webhook-execution' , payload , {
1133+ metadata : { workflowId : foundWorkflow . id , userId : actorUserId } ,
1134+ } )
1135+ logger . info (
1136+ `[${ options . requestId } ] Executing ${ foundWebhook . provider } webhook ${ jobId } inline`
1137+ )
11281138 void ( async ( ) => {
11291139 try {
11301140 await jobQueue . startJob ( jobId )
0 commit comments