File tree Expand file tree Collapse file tree 4 files changed +20
-8
lines changed
Expand file tree Collapse file tree 4 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export async function GET(
2727
2828 const dispatchJob = await getDispatchJobRecord ( taskId )
2929 const jobQueue = await getJobQueue ( )
30- const job = dispatchJob ? await jobQueue . getJob ( taskId ) : await jobQueue . getJob ( taskId )
30+ const job = dispatchJob ? null : await jobQueue . getJob ( taskId )
3131
3232 if ( ! job && ! dispatchJob ) {
3333 return createErrorResponse ( 'Task not found' , 404 )
Original file line number Diff line number Diff line change @@ -115,11 +115,10 @@ export async function GET(request: NextRequest) {
115115 }
116116
117117 try {
118- const workspaceId = schedule . workflowId
119- ? ( await import ( '@/lib/workflows/utils' ) ) . getWorkflowById
118+ const { getWorkflowById } = await import ( '@/lib/workflows/utils' )
119+ const resolvedWorkflow = schedule . workflowId
120+ ? await getWorkflowById ( schedule . workflowId )
120121 : null
121- const resolvedWorkflow =
122- schedule . workflowId && workspaceId ? await workspaceId ( schedule . workflowId ) : null
123122 const resolvedWorkspaceId = resolvedWorkflow ?. workspaceId
124123
125124 let jobId : string
Original file line number Diff line number Diff line change @@ -812,6 +812,17 @@ async function handleExecutePost(
812812 ( preprocessResult . executionTimeout ?. sync ?? 300000 ) + 30000
813813 )
814814
815+ if ( resultRecord . status === 'failed' ) {
816+ return NextResponse . json (
817+ {
818+ success : false ,
819+ executionId,
820+ error : resultRecord . error ?? 'Workflow execution failed' ,
821+ } ,
822+ { status : 500 }
823+ )
824+ }
825+
815826 const result = resultRecord . output as QueuedWorkflowExecutionResult
816827
817828 const resultForResponseBlock = {
@@ -977,8 +988,8 @@ async function handleExecutePost(
977988 }
978989
979990 if ( shouldUseDraftState ) {
980- const useDispatchForManual = shouldUseBullMQ ( ) && triggerType !== 'manual'
981- if ( useDispatchForManual ) {
991+ const shouldDispatchViaQueue = shouldUseBullMQ ( ) && triggerType !== 'manual'
992+ if ( shouldDispatchViaQueue ) {
982993 const metadata : ExecutionMetadata = {
983994 requestId,
984995 executionId,
Original file line number Diff line number Diff line change @@ -15,7 +15,9 @@ export interface AdmissionTicket {
1515/**
1616 * Attempts to admit a request through the in-process gate.
1717 * Returns a ticket with a release() handle on success, or null if at capacity.
18- * Zero external calls — purely in-process atomic counter.
18+ * Zero external calls — purely in-process atomic counter. Each pod maintains its
19+ * own counter, so the effective aggregate limit across N pods is N × MAX_INFLIGHT.
20+ * Configure ADMISSION_GATE_MAX_INFLIGHT per pod based on what each pod can sustain.
1921 */
2022export function tryAdmit ( ) : AdmissionTicket | null {
2123 if ( inflight >= MAX_INFLIGHT ) {
You can’t perform that action at this time.
0 commit comments