From c0e7f7412e0a8056e3cfe922a4c842fb58dee09f Mon Sep 17 00:00:00 2001 From: Moepchi Date: Fri, 18 Sep 2026 10:47:35 +0000 Subject: [PATCH] Lower design store cap to bound worst-case RAM usage STORE_MAX_THEMES was 2000, meaning the in-memory store cache could theoretically grow to ~900MB (2000 * up to 450KB CSS+screenshot each) with no eviction. 300 bounds that to ~135MB, which is proportionate for what is currently a niche community design store. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU --- gateway/src/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gateway/src/index.ts b/gateway/src/index.ts index 723e618..e5058c9 100644 --- a/gateway/src/index.ts +++ b/gateway/src/index.ts @@ -342,9 +342,10 @@ const STORE_CSS_MAX_LENGTH = 50_000; // flat JSON file as everything else, so this also bounds that file's growth. const STORE_SCREENSHOT_MAX_DATA_URL_LENGTH = 400_000; const STORE_SCREENSHOT_RE = /^data:image\/(png|jpe?g|webp);base64,[A-Za-z0-9+/]+=*$/; -// Hard cap so the flat file can't grow unbounded from spam that slips past -// rate limiting (a fresh IP per submission, say). -const STORE_MAX_THEMES = 2000; +// Hard cap so the flat file - and the in-memory cache mirroring it - can't +// grow unbounded from spam that slips past rate limiting (a fresh IP per +// submission, say). Bounds worst case to ~300 * 450KB =~ 135MB in RAM. +const STORE_MAX_THEMES = 300; const STORE_BASE_THEMES = new Set(["standard", "nova", "greenteaspeak", "pulse"]); // A handful of names (the operator's own) that only whoever holds