fix(Wait Node): Account for workflow timezone in Wait node datetime (#8578)

Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
Iván Ovejero 2024-02-14 16:12:23 +01:00 committed by GitHub
parent a2a3ca160f
commit 1116a28b45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View file

@ -151,7 +151,6 @@ import Container from 'typedi';
import type { BinaryData } from './BinaryData/types';
import merge from 'lodash/merge';
import { InstanceSettings } from './InstanceSettings';
import { toUtcDate } from './utils';
axios.defaults.timeout = 300000;
// Prevent axios from adding x-form-www-urlencoded headers by default
@ -3560,7 +3559,7 @@ export function getExecuteFunctions(
binaryToBuffer: async (body: Buffer | Readable) =>
await Container.get(BinaryDataService).toBuffer(body),
async putExecutionToWait(waitTill: Date): Promise<void> {
runExecutionData.waitTill = toUtcDate(waitTill, getTimezone(workflow));
runExecutionData.waitTill = waitTill;
if (additionalData.setExecutionStatus) {
additionalData.setExecutionStatus('waiting');
}

View file

@ -1,3 +1,4 @@
import { DateTime } from 'luxon';
import type {
IExecuteFunctions,
INodeExecutionData,
@ -29,7 +30,6 @@ import {
} from '../Form/common.descriptions';
import { formWebhook } from '../Form/utils';
import { updateDisplayOptions } from '../../utils/utilities';
import { Webhook } from '../Webhook/Webhook.node';
const waitTimeProperties: INodeProperties[] = [
@ -420,12 +420,17 @@ export class Wait extends Webhook {
waitAmount *= 1000;
// Timezone does not change relative dates, since they are just
// a number of seconds added to the current timestamp
waitTill = new Date(new Date().getTime() + waitAmount);
} else {
// resume: dateTime
const dateTime = context.getNodeParameter('dateTime', 0) as string;
const dateTimeStr = context.getNodeParameter('dateTime', 0) as string;
waitTill = new Date(dateTime);
waitTill = DateTime.fromFormat(dateTimeStr, "yyyy-MM-dd'T'HH:mm:ss", {
zone: context.getTimezone(),
})
.toUTC()
.toJSDate();
}
const waitValue = Math.max(waitTill.getTime() - new Date().getTime(), 0);