[openstreetmap/openstreetmap-website] Deprecate Timeout in favor of DB and request timeouts (Issue #6572)

rkoeze notifications at github.com
Sun Nov 30 21:20:20 UTC 2025


rkoeze created an issue (openstreetmap/openstreetmap-website#6572)

### Problem

We currently use Ruby’s Timeout to guard against long-running operations, including DB queries. This has a few issues:

- Timeout can inject an exception into a thread at essentially any point. That kind of behavior is hard to reason about. [It can also leave resources in an inconsistent state](https://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/). 
- Rails may wrap these exceptions, so we have to add monkeypatches [like this](https://github.com/openstreetmap/openstreetmap-website/blob/0d93c131fa13ef238cee2ba3e63abd404cb05fce/config/initializers/abstract_adapter.rb). 
- We still see long running queries despite those queries being wrapped with Timeout.

### Description

We should not rely on the Timeout library for long running operations. As an alternative, we might consider doing the following:
* Use DB-level timeouts (e.g. `statement_timeout`) with a reasonable default. We recently added [a 5 minute timeout](https://github.com/openstreetmap/chef/commit/2943e2cb7e273b139f796fee86323b4882461340) as a backstop. I would recommend bumping that down.
* Ensure all network requests are also guarded by a timeout.
* For other long running code inside our application, consider explicit deadline checks.

Not having access to data on request and DB query times, it's a little hard to say what these timeout values should be.

### Screenshots

_No response_

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/6572
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/issues/6572 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20251130/ac6e3d11/attachment.htm>


More information about the rails-dev mailing list