Hi everyone,
I’m running into an issue where my workflow keeps going into an infinite execution loop.
Here’s my setup:
-
Trigger: Gmail Trigger (Unread emails only)
-
Next step: Gmail → Get Many Messages
-
In the Received After field, I’m using this expression:
{{ new Date().toISOString().slice(0,10) + 'T00:00:00' }} -
The result is always something like
2025-09-27T00:00:00.
The problem is that every time the workflow executes, this expression recalculates to today’s midnight. As a result, Gmail keeps returning the same set of emails, which triggers the workflow again → causing an endless loop.
My question:
What’s the best practice in n8n to avoid this loop? Should I:
-
Rely only on Gmail Trigger and remove the “Get Many Messages” node?
-
Use
$nowor$prevNodeto calculate a relative time range instead of resetting to midnight every run? -
Or is there a way to de-duplicate emails (by ID or threadId) so they don’t keep re-triggering the workflow?
I’d appreciate any suggestions or examples of how you’ve handled this problem. Thanks!
