Skip to content
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

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

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 1 addition & 2 deletions packages/core/src/NodeExecuteFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,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
Expand Down Expand Up @@ -3537,7 +3536,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;
krynble marked this conversation as resolved.
Show resolved Hide resolved
if (additionalData.setExecutionStatus) {
additionalData.setExecutionStatus('waiting');
}
Expand Down
15 changes: 10 additions & 5 deletions packages/nodes-base/nodes/Wait/Wait.node.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DateTime } from 'luxon';
import type {
IExecuteFunctions,
INodeExecutionData,
Expand Down Expand Up @@ -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[] = [
Expand Down Expand Up @@ -420,12 +420,17 @@ export class Wait extends Webhook {

waitAmount *= 1000;

waitTill = new Date(new Date().getTime() + waitAmount);
const original = new Date(new Date().getTime() + waitAmount);

waitTill = DateTime.fromISO(original.toISOString().slice(0, -1)).toUTC().toJSDate();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth considering moving the toUtcDate to the nodes package as well as its tests? WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I just tested it now, and it looks real bad. It now takes into account the timezone, so it seems it startec picking up America/New York so instead of my workflows waiting 10 minutes, they now way 5 hours and 10 minutes, which is even worse 😓

But to make things even more interesting, I changed the workflow's timezone, and it's also being completely ignored.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate? This is how I tested:

  • Selected 12:00 with workflow set at UTC-5 → Stored as 17:00 UTC in DB
  • Selected +2h with workflow set at 10:40 UTC-5 → Stored as 17:40 UTC in DB

These are what I'd expect to be correct. What am I missing?

} 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", {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix timezone only for specific points in time, where 4pm is something in UK vs Berlin.

zone: context.getTimezone(),
})
.toUTC()
.toJSDate();
}

const waitValue = Math.max(waitTill.getTime() - new Date().getTime(), 0);
Expand Down
Loading