05-Jun-2026 — reduce request memory pressure with lean reads, tile timeout and capped queries ref #285
build 668 — commit c8bedc9
What's New
Two rounds of request-memory work, combined. Server read queries now return plain objects instead of full Mongoose documents, the OS Maps tile proxy gives up on a hung upstream rather than holding the request open, and unbounded "all" queries are capped so a large dataset cannot exhaust the machine's memory.
Related issue: #285 - perf(walks): unbounded event queries cause request-memory OOM on large area-scoped sites
How it behaves
- Read queries (findOne, findById, find, paginated find) use
.lean(), returning plain objects and skipping Mongoose document hydration, which is the main per-request memory cost on large result sets. - The OS Maps tile proxy now times out an upstream request after 10 seconds and returns 504, so a stalled tile fetch cannot pile up and hold memory.
- The non-paginated
allquery branch caps at 1000 documents when no explicit limit is supplied, logging a warning that names the model and criteria. Callers passing an explicit limit are unaffected. - The walks map view passes an explicit limit so map loading is intentionally bounded.
Why it matters
On area-scoped sites (for example Kent, with 4205 events) an unbounded "all events" query returned every matching document as full Mongoose objects, driving Firecracker memory toward the 512MB ceiling; a live test returned HTTP 503 after 35 seconds. Group sites hold a fraction of the data so never hit this. It matters for the Ramblers HQ rollout, where many large area-scoped sites are expected.
Technical changes
- crud-controller:
.lean()on findOne, findOneDocument, both find branches and findById; new UNPAGINATED_RESULT_CAP (1000) applied to the non-paginated branch when no explicit limit, with a warning log on truncation. - os-maps-proxy: 10 second upstream request timeout returning 504 on a stalled tile fetch.
- events-full map view and map.model: explicit MAP_VIEW_MAX_EVENTS (1000) limit on the map query.