You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Route remaining proxies through handle_store_error and document
Applies handle_store_error in RedisStoreProxy, RedisCacheStoreProxy and
MemCacheStoreProxy so their calls participate in the shared bypass
mechanism. Adds cross-proxy specs pinning each subclass default and
documents bypassable_store_errors in the README.
Copy file name to clipboardExpand all lines: README.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -315,6 +315,35 @@ Most applications should use a new, separate database used only for `rack-attack
315
315
316
316
Note that `Rack::Attack.cache` is only used for throttling, allow2ban and fail2ban filtering; not blocklisting and safelisting. Your cache store must implement `increment` and `write` like [ActiveSupport::Cache::Store](http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html). This means that other cache stores which inherit from ActiveSupport::Cache::Store are also compatible. In-memory stores which are not backed by an external database, such as `ActiveSupport::Cache::MemoryStore.new`, will be mostly ineffective because each Ruby process in your deployment will have it's own state, effectively multiplying the number of requests each client can make by the number of Ruby processes you have deployed.
317
317
318
+
#### Bypassing store errors
319
+
320
+
By default, some store proxies will swallow the errors they historically rescued (`Redis::BaseConnectionError` for `Redis`, `Dalli::DalliError` for `Dalli`). When one of those errors is raised inside the proxy, the request goes through as if no throttling were applied, which keeps your app available if the dedicated rack-attack store goes down.
321
+
322
+
You can customize this behavior through `Rack::Attack.cache.bypassable_store_errors`:
323
+
324
+
```ruby
325
+
# Use the proxy's built-in defaults (this is the default)
# Bypass ALL errors raised by the store — requests continue serving even if the
329
+
# store misbehaves in unexpected ways (e.g. Redis OOM, timeouts, protocol errors).
330
+
Rack::Attack.cache.bypassable_store_errors =:all
331
+
332
+
# Bypass NO errors — any error from the store will propagate. This disables the
333
+
# proxy's historical default rescue behavior as well.
334
+
Rack::Attack.cache.bypassable_store_errors =:none
335
+
336
+
# Bypass a specific list of error classes (or class-name Strings). This REPLACES
337
+
# the proxy's built-in defaults - include any you still want to rescue.
338
+
Rack::Attack.cache.bypassable_store_errors = [
339
+
Redis::BaseConnectionError,
340
+
Redis::TimeoutError,
341
+
"Redis::CommandError"
342
+
]
343
+
```
344
+
345
+
`bypassable_store_errors` can be set before or after assigning `cache.store`; the store is re-wrapped automatically.
346
+
318
347
## Customizing responses
319
348
320
349
Customize the response of blocklisted and throttled requests using an object that adheres to the [Rack app interface](http://www.rubydoc.info/github/rack/rack/file/SPEC.rdoc).
0 commit comments