replace location only on waiting forms

This commit is contained in:
Michael Kret 2025-03-03 12:39:24 +02:00
parent 293128230b
commit 75ab8988d9
2 changed files with 20 additions and 4 deletions

View file

@ -1,7 +1,12 @@
import { Service } from '@n8n/di';
import type express from 'express';
import type { IRunData } from 'n8n-workflow';
import { FORM_NODE_TYPE, WAITING_FORMS_EXECUTION_STATUS, Workflow } from 'n8n-workflow';
import {
FORM_NODE_TYPE,
WAIT_NODE_TYPE,
WAITING_FORMS_EXECUTION_STATUS,
Workflow,
} from 'n8n-workflow';
import { ConflictError } from '@/errors/response-errors/conflict.error';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
@ -74,8 +79,19 @@ export class WaitingForms extends WaitingWebhooks {
const execution = await this.getExecution(executionId);
if (suffix === WAITING_FORMS_EXECUTION_STATUS) {
res.send(execution?.status ?? null);
if (execution && suffix === WAITING_FORMS_EXECUTION_STATUS) {
let status: string = execution?.status;
const { node } = execution.data.executionData?.nodeExecutionStack[0] ?? {};
if (node && status === 'waiting') {
if (node.type === FORM_NODE_TYPE) {
status = 'form-waiting';
}
if (node.type === WAIT_NODE_TYPE && node.parameters.resume === 'form') {
status = 'form-waiting';
}
}
res.send(status ?? null);
return { noWebhookResponse: true };
}

View file

@ -779,7 +779,7 @@
const response = await fetch(`${formWaitingUrl ?? window.location.href}/n8n-execution-status`);
const text = (await response.text()).trim();
if (text === "waiting") {
if (text === "form-waiting") {
window.location.replace(formWaitingUrl ?? window.location.href);
return;
}