From c2511a829cfa40d4d9d570ad7724845c93544c3b Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Mon, 24 Jul 2023 17:29:38 +0300 Subject: [PATCH] fix(Gmail Trigger Node): Early returns in case of no data (#6727) --- .../nodes-base/nodes/Google/Gmail/GmailTrigger.node.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/Google/Gmail/GmailTrigger.node.ts b/packages/nodes-base/nodes/Google/Gmail/GmailTrigger.node.ts index 83c89147fc..40b1f28484 100644 --- a/packages/nodes-base/nodes/Google/Gmail/GmailTrigger.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/GmailTrigger.node.ts @@ -257,8 +257,9 @@ export class GmailTrigger implements INodeType { ); responseData = responseData.messages; - if (responseData === undefined) { - responseData = []; + if (!responseData?.length) { + webhookData.lastTimeChecked = endDate; + return null; } const simple = this.getNodeParameter('simple') as boolean; @@ -312,6 +313,11 @@ export class GmailTrigger implements INodeType { ); } + if (!responseData?.length) { + webhookData.lastTimeChecked = endDate; + return null; + } + const getEmailDateAsSeconds = (email: IDataObject) => { const { internalDate, date } = email; return internalDate