---
title: "sleep | Speedscale Docs"
description: "Pause the chain for a configured duration using the sleep transform in Speedscale, useful for pacing replay traffic or simulating client think-time."
canonical: "https://docs.speedscale.com/guides/transformation/transforms/sleep/"
---

[Documentation index](https://docs.speedscale.com/guides/llms.txt) | [Markdown](https://docs.speedscale.com/guides/transformation/transforms/sleep/index.md) | [Canonical page](https://docs.speedscale.com/guides/transformation/transforms/sleep/)

# sleep

The `sleep` transform pauses the chain for a fixed duration. The chain's token is passed through unchanged — the only effect is the delay.

It is the simplest way to insert deliberate think-time between RRPairs or to slow a chain down for debugging.

*   **Transform type name (config/API):** `sleep`
*   **Shorthand format:** `sleep(duration=...)`

<a id="quick-start"></a>

## Quick Start

Pause for 150 milliseconds before the rest of the chain proceeds:

```json
"type": "sleep",
"config": {
    "duration": "150ms"
}
```

If `duration` is omitted, the transform defaults to **1000ms** (1 second).

<a id="how-it-works"></a>

## How It Works

`sleep` does all of its work in the first phase. The second phase is a no-op.

1.  **First phase** — block the current goroutine for the configured duration, then return the token unchanged.
2.  **Second phase** — pass the token through.

The pause applies to the single chain evaluation the transform runs in. Concurrent chains on other RRPairs or other [vUsers](https://docs.speedscale.com/reference/glossary/#vuser) are unaffected — they have their own goroutines and are not blocked by this one's sleep.

<a id="scope-of-the-delay"></a>

### Scope of the Delay

*   A `sleep` in a **request-side** chain delays the surrounding request flow for the current vUser before the request is sent.
*   A `sleep` in a **response-side** chain delays processing after the response is received but before downstream chains and the next RRPair on the same vUser run.
*   Other vUsers, other RRPairs, and other chains on different RRPairs continue independently.

There is no jitter, no skew correction, and no cancellation. Once the pause starts, it runs to completion.

<a id="configuration"></a>

## Configuration

```json
"type": "sleep",
"config": {
    "duration": "<Go duration string>"
}
```

| Parameter | Required | Default | Description |
| --- | --- | --- | --- |
| `duration` | No | `1000ms` | Length of the pause. Standard Go duration string: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. Examples: `150ms`, `2s`, `1m30s`. An unparseable value fails chain initialization. `0s` is accepted and produces effectively no delay. |

<a id="examples"></a>

## Examples

<a id="example-1--pace-request-bursts"></a>

### Example 1 — Pace request bursts

```json
"type": "sleep",
"config": {
    "duration": "200ms"
}
```

Inserts a 200ms pause in the chain — useful for slowing down a tight loop of requests on a single vUser.

<a id="example-2--default-1-second-pause"></a>

### Example 2 — Default 1-second pause

```json
"type": "sleep"
```

With no `duration`, the pause is 1 second.

<a id="example-3--chain-it-after-an-extractor-for-diagnostic-timing"></a>

### Example 3 — Chain it after an extractor for diagnostic timing

```text
req_body() → json_path(path="id") → sleep(duration=500ms)
```

The chain extracts `id`, waits 500ms, and continues. The token is unchanged through the pause.

<a id="common-misconceptions"></a>

## Common Misconceptions

1.  **"`sleep` pauses the entire replay."** No. The pause is confined to the goroutine running the current chain — typically one vUser's traffic. Other vUsers and other chains continue running.
    
2.  **"`sleep` modifies the token."** No. The token passes through unchanged. If you need both a delay and a value change, chain `sleep` together with another transform.
    
3.  **"You can cancel a `sleep` partway through."** No. The pause runs to completion. Use a smaller duration if you need finer control.
    
4.  **"Duration `0s` is rejected."** No. `0s` is a valid duration and produces effectively no pause; the chain continues immediately.
    

<a id="troubleshooting"></a>

## Troubleshooting

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| Chain init: `could not parse duration: ...` | `duration` is not a valid Go duration string | Use formats like `150ms`, `2s`, `1m30s` |
| Replay throughput collapses | A long `sleep` is running on every RRPair across many vUsers | Reduce the duration, or move the `sleep` to a chain that runs less often |
| Pause is much longer than configured | The host is heavily loaded; Go runtime cannot wake the goroutine on time | Investigate generator host load — `sleep` itself does not over-shoot intentionally |
| Pause appears to do nothing | `duration` is very small relative to surrounding RRPair latency | Increase `duration`, or measure with a finer-grained tool |

<a id="related-transforms"></a>

## Related Transforms

*   [`constant`](https://docs.speedscale.com/guides/transformation/transforms/constant/), [`replace`](https://docs.speedscale.com/guides/transformation/transforms/replace/) — for value-changing transforms when a pure delay isn't what you want.
*   [`var_store`](https://docs.speedscale.com/guides/transformation/transforms/variable_store/), [`var_load`](https://docs.speedscale.com/guides/transformation/transforms/variable_load/) — for carrying values across RRPairs without delay.

<a id="advanced-notes"></a>

## Advanced Notes

*   `sleep` reports no required Kubernetes secrets and does not consult the variable cache.
*   The default duration of 1 second is applied when `duration` is omitted entirely from the config. Passing `duration: ""` (empty string) is treated as missing and gets the default; passing `duration: "0s"` runs with no delay.
*   The transform does not require recorded response data to run.
