Skip to content

Commit

Permalink
fix(Wait Node): Prevent waiting until invalid date (#10523)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov authored Aug 27, 2024
1 parent fd58a27 commit c0e7620
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/nodes-base/nodes/Wait/Wait.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
IDisplayOptions,
IWebhookFunctions,
} from 'n8n-workflow';
import { WAIT_TIME_UNLIMITED } from 'n8n-workflow';
import { WAIT_TIME_UNLIMITED, NodeOperationError } from 'n8n-workflow';

import {
authenticationProperty,
Expand Down Expand Up @@ -346,6 +346,7 @@ export class Wait extends Webhook {
},
default: '',
description: 'The date and time to wait for before continuing',
required: true,
},

// ----------------------------------
Expand Down Expand Up @@ -492,6 +493,13 @@ export class Wait extends Webhook {
} else {
const dateTimeStr = context.getNodeParameter('dateTime', 0) as string;

if (isNaN(Date.parse(dateTimeStr))) {
throw new NodeOperationError(
context.getNode(),
'[Wait node] Cannot put execution to wait because `dateTime` parameter is not a valid date. Please pick a specific date and time to wait until.',
);
}

waitTill = DateTime.fromFormat(dateTimeStr, "yyyy-MM-dd'T'HH:mm:ss", {
zone: context.getTimezone(),
})
Expand Down

0 comments on commit c0e7620

Please sign in to comment.