MESA Docs
MESA Homepage
  • Welcome to MESA
    • Installing MESA
    • Dashboard
    • Core Concepts
    • Getting Help
  • Templates
    • Template Library
    • Installing & Editing
  • Workflow Builder
    • Triggers
    • Actions
    • Fields
      • Variables
      • Formatting Variables
      • Liquid Templating
    • Testing
  • Workflow Activity
    • Tasks
      • Troubleshooting
      • Replay
    • Logs
    • Time Travel
  • Best Practices
    • Set Titles & Descriptions
    • Track Time Saved
    • Enable Failure Notifications
    • Avoid Infinite Loops
  • Going Further
    • Plans & Billing
    • Notifications
    • Credentials
    • Understanding the Queue
    • Export & Import Workflows
    • Platform Thresholds & Limits
  • Built-in Tools
    • Activity Log
    • AI
    • API
    • Approval
    • MCP
    • Custom Code
      • Libraries
        • MESA SDK
        • Filter
        • Loop
        • Transform
        • oAuth
        • Shopify
        • ShopifyGraphql
      • FAQ
    • Data
    • Delay
    • Email
    • Filter
    • Form
      • Configure
      • Going Further
      • Technical Notes
    • FTP
    • Image
    • Loop
    • Package Tracking
    • Paths
    • Schedule
    • Scraper
    • SMS
    • Transform
    • Virtual Output
    • Weather
    • Web Request
    • Webhook
  • Apps
    • Airtable
    • Amazon S3
    • Asana
    • Blog Studio
    • ChannelApe
    • Claude
    • ChatGPT
    • Dall-E 2
    • Delighted
    • Digital Humani
    • Discord
    • DocuSign
    • Dropbox
    • Etsy
    • Facebook
    • Fera.ai
    • Gatsby
    • Gmail
      • Send Email
    • Google Analytics 4
    • Google Analytics UA
    • Google Calendar
    • Google Drive
    • Google Forms
    • Google Sheets
      • Add Row
      • Query Rows
      • Update Row
      • Row Created
      • Row Updated (Advanced)
      • Creating New Spreadsheets
      • Technical Notes
    • Gorgias
    • Govalo
    • Help Scout
    • Hubspot
    • Infinite Options
    • Intercom
    • IPDetective
    • Judge.me
    • Katana
    • Klaviyo
      • API Deprecation
    • Loop Returns
    • Loyalty Lion
    • Mailchimp
    • Mailgun
    • Mandrill
    • Mantle
    • Notion
    • Odoo
    • Omnisend
    • Page Studio
    • Pinterest
    • Printful
    • PrintNode
    • QuickBooks
    • Rebuy
    • Recharge
    • Remove.bg
    • Returnly
    • Rivo
    • Salesforce
    • Segment
    • Sendlane
    • Shippo
    • ShipStation
    • Shopify
      • Technical Notes
        • Configuring Your Payload
        • Modifying and Filtering Get Lists
        • Parameters
        • Error Codes
        • Accuracy of orders_count Variable
        • Accuracy of Count Products Action
        • Using the Gift Cards API
        • How to Find a Specific Record in the Testing Interface
        • Order, Customer, and Product Updated Trigger Frequency
    • Shopify Flow
    • Shopify Plus
    • Shopify Retail POS
    • Skio Subscriptions
    • Slack
    • Smartrr
    • Smile.io
    • Square
      • Updating Inventory
      • Frequently Asked Questions
    • Stamped.io
    • Stripe
    • Thanks.io
    • TikTok
    • Tracktor
    • Twilio
    • Uploadery
    • Wonderment
    • Xero
    • Yotpo
    • Yotpo Loyalty
  • For developers
    • Admin API
    • Command Line Interface
    • Embedding templates
  • Frequently asked questions
    • Why isn't the log search returning logs with the search I entered?
    • Is it possible to handle errors or retry steps?
    • How do I handle a failed task?
    • Does MESA auto-save workflows?
    • Can I Use Apps That Don't Have a MESA Connector?
    • Why is my workflow action adding the same data each time it occurs?
    • How do I cancel automations that are already in progress?
    • How do I cancel my MESA subscription or 7-day trial?
    • Can you import code from npm in custom code?
    • Do you have a Slack Community?
Powered by GitBook
On this page
  • Bi-directional sync
  • Workflows affecting the same object
  • Suggested structure
  • Suggested structure using specific fields

Was this helpful?

  1. Best Practices

Avoid Infinite Loops

PreviousEnable Failure NotificationsNextGoing Further

Last updated 10 months ago

Was this helpful?

If your workflow triggers an infinite loop, it could flood your message queue, slow down workflow processing, or worse, result in large overage charges.

Workflows with an Update trigger can be at risk of causing an infinite loop in a couple different situations:

Bi-directional sync

Consider a scenario to copy orders and keep inventory levels in sync with two workflows:

  • When a Shopify order is created, create an order in Salesforce

  • When a Salesforce order is created, create an order in Shopify

When a Shopify order is placed, the first workflow will run which will create a Salesforce order. This will trigger the second workflow, which will in turn trigger the first workflow. Now you have a never-ending loop of new orders.

Workflows affecting the same object

Consider this workflow that begins with a Product updated step and contains an Update product step:

When a Shopify product is updated, this workflow will be triggered and the same product will be updated. This will in turn trigger the workflow again, which could cause he product to be updated, and so on. MESA has special handling for duplicate messages which works in most cases, but not all, depending on the updates you are making.

Suggested structure

To avoid infinite loops, we always recommend adding a unique identifier to the object that was updated and then filtering by that identifier in the second step of your workflow. In the above example, you would add a Shopify add tag step to the end of the workflow that adds a "AI Update" tag:

And then confirm that the product does not contain that tag in the second step of the workflow:

The remedy for a bi-directional sync would be similar, but you would want to check that the tag does not exist in both workflows.

This would result in your automation running twice every time the product is updated (once to make the update, and a second time to hit the filter), which should be accounted for when selecting a plan.

Suggested structure using specific fields

If you're updating an object and don't need to read it, you can select Only when specific fields change to avoid infinite loops. For example, if you're updating tags but don't need to read them in the workflow, use the Only when specific fields change feature to include all the fields you're reading and exclude those you're not using, like tags. Doing so prevents the workflow from getting triggered when the only change is a tag modification.

In the example below, we have set a value for Fields. The workflow will only be triggered when the title, body html, or variants are updated. Because tags are not included in the Include Fields value, updates to the product tags will not trigger the workflow. This structure prevents the workflow from being executed twice.

Uh oh, how do I make it stop?!
Now I know that MESA has updated the product!