---
title: "Max wait & fail fast — HTTP Client Rate Limits for Laravel | Roundly"
description: "Cap how long a call may wait; above the ceiling it throws RateLimitExceededException instead of blocking."
url: https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel/max-wait
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[HTTP Client Rate Limits for Laravel](https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel.md)

# Max wait & fail fast

When you’d rather error than block for too long, cap the wait. A wait above the ceiling — counting every round of it, if the limiter has to wait again after losing a slot to another worker — throws RateLimitExceededException (extends RateLimitException) instead of sleeping:

```php
Http::rateLimit(RateLimits::perHour(10)->maxWait(5_000)) // milliseconds
    ->get('https://api.example.com/report');
```

## Handling the exception

The exception carries the owner key, the wait that would have been needed and your ceiling, so you can reschedule, degrade or report precisely:

```php
use RoundlyConsulting\HttpClientRateLimits\Exceptions\RateLimitExceededException;
use RoundlyConsulting\HttpClientRateLimits\Facades\RateLimits;

try {
    $response = Http::rateLimit(RateLimits::perHour(10)->maxWait(5_000))
        ->get('https://api.example.com/report');
} catch (RateLimitExceededException $e) {
    $e->key;        // the owner key of the window that forced the wait
    $e->delayMs;    // the wait that would have been needed
    $e->maxWaitMs;  // your ceiling (5000)
}
```

The check runs before the RequestDeferred event and before any waiting, so nothing is recorded for the rejected call. In a named profile, set it with the max\_wait key (milliseconds).

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel.md)
