Skip to content

fix(core): Resolves response promise for active execution on job finished in queue mode #15643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cli/src/scaling/scaling.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ export class ScalingService {
this.activeExecutions.resolveResponsePromise(msg.executionId, decodedResponse);
break;
case 'job-finished':
this.activeExecutions.resolveResponsePromise(msg.executionId, {});
this.logger.info(`Execution ${msg.executionId} (job ${jobId}) finished successfully`, {
workerId: msg.workerId,
executionId: msg.executionId,
Expand Down
18 changes: 18 additions & 0 deletions packages/cli/src/webhooks/__tests__/webhook-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ describe('autoDetectResponseMode', () => {
expect(result).toBe('responseNode');
});

test('should return formPage when start node is FORM_NODE_TYPE and method is POST and there is a following FORM_NODE_TYPE node', () => {
const workflowStartNode = mock<INode>({
type: FORM_NODE_TYPE,
name: 'startNode',
parameters: {},
});
workflow.getChildNodes.mockReturnValue(['childNode']);
workflow.nodes.childNode = mock<INode>({
type: FORM_NODE_TYPE,
parameters: {
operation: 'completion',
},
disabled: false,
});
const result = autoDetectResponseMode(workflowStartNode, workflow, 'POST');
expect(result).toBe('formPage');
});

test('should return undefined when start node is FORM_NODE_TYPE with no other form child nodes', () => {
const workflowStartNode = mock<INode>({
type: FORM_NODE_TYPE,
Expand Down
16 changes: 16 additions & 0 deletions packages/cli/src/webhooks/webhook-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export function getWorkflowWebhooks(
return returnData;
}

// eslint-disable-next-line complexity
export function autoDetectResponseMode(
workflowStartNode: INode,
workflow: Workflow,
Expand All @@ -125,6 +126,21 @@ export function autoDetectResponseMode(
}
}

// If there are form nodes connected to a current form node we're dealing with a multipage form
// and we need to return the formPage response mode when a second page of the form gets submitted
// to be able to show potential form errors correctly.
if (workflowStartNode.type === FORM_NODE_TYPE && method === 'POST') {
const connectedNodes = workflow.getChildNodes(workflowStartNode.name);

for (const nodeName of connectedNodes) {
const node = workflow.nodes[nodeName];

if (node.type === FORM_NODE_TYPE && !node.disabled) {
return 'formPage';
}
}
}

if (workflowStartNode.type === WAIT_NODE_TYPE && workflowStartNode.parameters.resume !== 'form') {
return undefined;
}
Expand Down
13 changes: 9 additions & 4 deletions packages/cli/templates/form-trigger.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,7 @@
document.querySelector('#submit-btn span').style.display = 'inline-block';

let postUrl = '';
if (window.location.href.includes('form-waiting')) {
intervalId = setTimeout(checkExecutionStatus, interval);
} else {
if (!window.location.href.includes('form-waiting')) {
postUrl = window.location.search;
}

Expand All @@ -880,7 +878,8 @@

if(json?.formWaitingUrl) {
formWaitingUrl = json.formWaitingUrl;
intervalId = setTimeout(checkExecutionStatus, interval);
clearTimeout(timeoutId);
timeoutId = setTimeout(checkExecutionStatus, interval);
return;
}

Expand Down Expand Up @@ -934,6 +933,12 @@
})
.catch(function (error) {
console.error('Error:', error);
})
.finally(() => {
if (window.location.href.includes('form-waiting')) {
clearTimeout(timeoutId);
timeoutId = setTimeout(checkExecutionStatus, interval);
}
});
}
});
Expand Down
Loading