sleep
Pauses the script for a number of seconds and returns its input unchanged. Use it when a script has to wait for an external system to finish something asynchronous before it can continue.
{% assign ignore = "" | sleep: 10 %}Syntax
{{ value | sleep }}
{{ value | sleep: seconds }}value
Any value. It is returned unchanged
seconds
Optional. Seconds to wait, maximum 600. Defaults to 1
Return Value
Returns the input value after the pause.
Examples
Wait for an external job to finish before reading its result:
{% assign status = "pending" %}
{% while status == "pending" %}
{% assign ignore = "" | sleep: 10 %}
{% http url: status_url, method: "GET" as check %}
{% assign status = check.body.status %}
{% endwhile %}Notes
Maximum 600 seconds per call. Longer waits fail with an error
The pause counts toward the script's execution timeout (24 hours for scheduled and event scripts, 60 seconds for HTTP and shipping scripts)
Not needed for API throttling. The
graphqlandhttptags already retry throttled requests with backoffOnly available in backend scripts, not in the storefront preview
Last updated