Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(play): lobby market feeds get their own rate-limit bucket + one-shot client retry

fudjia435652d202ac
diff --git a/api/_lib/rate-limit.js b/api/_lib/rate-limit.js
index 99f0b8729..9a6f030ca 100644
--- a/api/_lib/rate-limit.js
+++ b/api/_lib/rate-limit.js
@@ -751,6 +751,16 @@ export const limits = {
// Vercel) bounds one IP's throughput just as well without spending a Redis
// command per page view. The largest single source of avoidable quota burn.
publicIp: (ip) => getLimiter('public:ip', { limit: 60, window: '1 m', local: true }).limit(ip),
+ // Lobby-critical market feeds (/api/pump/trending, /api/pump/search). These
+ // render the /play lobby on every page load, sit behind a 30s server cache +
+ // stale fallback (so the upstream cost of a burst is near zero), and MUST NOT
+ // share the generic `publicIp` bucket: ~166 endpoints drain that one 60/min
+ // pool, so a browser with a few three.ws tabs open starves its own lobby and
+ // /play dead-ends on a 429 it did nothing to earn (same failure mode that
+ // moved /api/play/nonce to its own bucket — see playNonceIp below). local:
+ // per-instance flood guard is all a cached read needs.
+ marketFeedIp: (ip) =>
+ getLimiter('market-feed:ip', { limit: 120, window: '1 m', local: true }).limit(ip),
// Free x402 developer toolkit (echo / debug / verify-receipt). Free ≠
// abusable: these decode caller-supplied payment envelopes and recompute
// hashes, so 30/min per IP is generous for a developer iterating on their
diff --git a/api/pump/search.js b/api/pump/search.js
index 523fb19b9..ff4cbeae1 100644
--- a/api/pump/search.js
+++ b/api/pump/search.js
@@ -27,7 +27,9 @@ export default wrap(async (req, res) => {
if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
if (!method(req, res, ['GET'])) return;
- const rl = await limits.publicIp(clientIp(req));
+ // Same dedicated lobby bucket as /api/pump/trending — the /play coin search
+ // must not starve because unrelated endpoints drained the shared publicIp pool.
+ const rl = await limits.marketFeedIp(clientIp(req));
if (!rl.success) return rateLimited(res, rl);
const params = new URL(req.url, 'http://x').searchParams;
diff --git a/api/pump/trending.js b/api/pump/trending.js
index 84424a97e..47219e34c 100644
--- a/api/pump/trending.js
+++ b/api/pump/trending.js
@@ -81,7 +81,10 @@ export default wrap(async (req, res) => {
if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
if (!method(req, res, ['GET'])) return;
- const rl = await limits.publicIp(clientIp(req));
+ // Dedicated lobby bucket — NOT the shared publicIp pool. This feed renders the
+ // /play lobby on page load; sharing a 60/min bucket with ~166 other public
+ // endpoints meant any busy three.ws session 429'd its own lobby (2026-07-09).
+ const rl = await limits.marketFeedIp(clientIp(req));
if (!rl.success) return rateLimited(res, rl);
const params = new URL(req.url, 'http://x').searchParams;
diff --git a/data/changelog.json b/data/changelog.json
index 71e1018fd..722590a03 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -12639,6 +12639,15 @@
"tags": [
"fix"
]
+ },
+ {
+ "date": "2026-07-09",
+ "title": "The /play lobby no longer fails to load live coins during busy sessions",
+ "summary": "The live-coins grid on /play could show \"Could not load live coins right now\" because the market feed shared one rate-limit budget with more than 160 other endpoints — a busy session with a few tabs open starved its own lobby. Trending and coin search now have their own generous budget, and the lobby quietly retries once on a blip before ever showing the error card.",
+ "link": "/play",
+ "tags": [
+ "fix"
+ ]
}
]
}
diff --git a/src/game/coincommunities.js b/src/game/coincommunities.js
index 121db31ab..7e299d90d 100644
--- a/src/game/coincommunities.js
+++ b/src/game/coincommunities.js
@@ -530,11 +530,22 @@ export class CoinCommunities {
setTimeout(() => { boot?.dispose?.(); l.remove(); }, 600);
}
- async _loadCoins() {
+ async _loadCoins(attempt = 0) {
this.ui.setCoinsLoading();
try {
const r = await fetch(TRENDING_URL, { headers: { accept: 'application/json' } });
- if (!r.ok) throw new Error('HTTP ' + r.status);
+ if (!r.ok) {
+ // A 429/5xx here is almost always a blip (rate-limit window, deploy churn):
+ // the feed sits behind a 30s server cache, so one delayed retry usually
+ // lands. Only after that does the manual-retry error card appear.
+ if (attempt === 0 && (r.status === 429 || r.status >= 500)) {
+ const after = Number(r.headers.get('retry-after'));
+ const delayMs = Number.isFinite(after) && after > 0 ? Math.min(after, 30) * 1000 : 2500;
+ setTimeout(() => this._loadCoins(1), delayMs);
+ return;
+ }
+ throw new Error('HTTP ' + r.status);
+ }
const raw = await r.json();
this.ui.setCoins(mapCoins(raw));
} catch (err) {