sleep
hc.sleep(milliseconds)
Available since v2.0.0
Signature:(milliseconds: number) => Promise<void>
| Parameter | Type | Description |
|---|---|---|
milliseconds | | Required. Non-negative finite number of milliseconds to wait. 0 resolves on the next timer turn. |
Pauses the script for the given number of milliseconds, then continues. Use this to pace retries, wait before a follow-up hc.fetch, or add a short delay between script steps.
Use await — scripts are evaluated as async functions, so top-level await hc.sleep(...) is supported. The delay counts toward the script timeout.
Throws when the argument is negative, NaN, or otherwise not a finite number. The sandbox does not expose setTimeout / setInterval — use hc.sleep instead.
javascript
await hc.sleep(2000);