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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(price-history): share the market pool resolver so a throttled second lookup stops turning no_market into 502
nirholas6f577a2ed462
diff --git a/api/pump/price-history.js b/api/pump/price-history.jsindex cf5eea30d..ead1a4d03 100644--- a/api/pump/price-history.js+++ b/api/pump/price-history.js@@ -26,6 +26,7 @@import { cors, json, method, wrap, error, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';import { fetchBirdeyeOhlcv, birdeyeConfigured } from '../_lib/birdeye.js';+import { topPoolForToken } from '../_lib/market/ohlcv.js';const VALID_INTERVALS = new Set(['1m',@@ -197,31 +198,35 @@ async function geckoFetch(url, { timeoutMs }) {// state, not an upstream outage, so it must never be retried or served stale.class NoPoolError extends Error {}+// The pool lookup goes through the shared resolver in api/_lib/market/ohlcv.js+// (GeckoTerminal, then DexScreener's deepest pair, then Birdeye markets, with a+// shared last-good copy) rather than a second GeckoTerminal call of our own.+// The Birdeye rung above already ran that same resolver for this mint, and its+// GeckoTerminal reads are memoized per URL, so this lookup normally costs no+// request at all. It used to re-ask GeckoTerminal for the identical pools URL a+// few milliseconds later; on the shared Cloud Run egress that second call drew+// 429s, the throttle read as an outage, and a coin with no market anywhere got+// a 502 instead of the honest no_market answer (reproduced 2026-10-08).async function fetchGeckoPoolAddress(mint) {const hit = _poolCache.get(mint);if (hit && hit.expiresAt > Date.now()) return hit.address;- const url = `${GECKO_API}/networks/solana/tokens/${mint}/pools?page=1`;- const resp = await geckoFetch(url, { timeoutMs: 7000 });- // 404 = GeckoTerminal has never indexed this token: it has no market, which is- // an answer, not an outage. Any other non-OK status is a real upstream fault- // and must bubble so the caller can fall back to stale data.- if (resp.status === 404) {- _poolCache.set(mint, { address: null, expiresAt: Date.now() + POOL_TTL_MS });- return null;- }- if (!resp.ok) throw new Error(`GeckoTerminal pools ${resp.status}`);- const body = await resp.json().catch(() => null);- const pools = body?.data;- if (!Array.isArray(pools) || !pools.length) {- _poolCache.set(mint, { address: null, expiresAt: Date.now() + POOL_TTL_MS });- return null;+ let address;+ try {+ address = await withGeckoSlot(() => topPoolForToken(mint, 'solana'));+ } catch (err) {+ // 404 = no source indexes a market for this token: an answer, not an+ // outage. Any other status is a real upstream fault and must bubble so the+ // caller can fall back to the next rung or to stale data.+ if (err?.status === 404) {+ _poolCache.set(mint, { address: null, expiresAt: Date.now() + POOL_TTL_MS });+ return null;+ }+ throw err;}- // Prefer the pool with the most volume (first = highest by GeckoTerminal default ranking).- const address = pools[0]?.attributes?.address ?? null;- _poolCache.set(mint, { address, expiresAt: Date.now() + POOL_TTL_MS });+ _poolCache.set(mint, { address: address || null, expiresAt: Date.now() + POOL_TTL_MS });if (_poolCache.size > 512) _poolCache.delete(_poolCache.keys().next().value);- return address;+ return address || null;}async function fetchGeckoOhlcv({ mint, interval, from, to }) {diff --git a/data/changelog.json b/data/changelog.jsonindex 8f4c395a4..1ace31274 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,15 @@{"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security, desktop (desktop entries become the desktop app's release notes). `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-10-08",+ "title": "Coin charts say plainly when a coin has no market yet",+ "summary": "A coin with no trading pool anywhere could show a price-history error on its chart when a market data source was busy. The chart now recognises the coin has no market and shows the no-price-history state, and it asks that source one question fewer per chart load.",+ "tags": [+ "fix"+ ],+ "link": "/terminal"+ },{"date": "2026-10-08","title": "3D Studio results now hand every agent plain links to the model",diff --git a/tests/api/pump-price-history-resilience.test.js b/tests/api/pump-price-history-resilience.test.jsindex f0bf0646c..a0c6081a9 100644--- a/tests/api/pump-price-history-resilience.test.js+++ b/tests/api/pump-price-history-resilience.test.js@@ -46,15 +46,19 @@ function makeRes() {}function getJson(res) { return JSON.parse(res._body); }+// Real Response objects: the pool lookup runs through the shared market+// resolver (api/_lib/market/ohlcv.js), which reads bodies and headers the way+// fetch hands them back.+function jsonResponse(status, body) {+ return new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } });+}function poolResponse() {- return { ok: true, status: 200, json: async () => ({ data: [{ attributes: { address: POOL } }] }) };+ return jsonResponse(200, { data: [{ attributes: { address: POOL } }] });}function ohlcvResponse() {- return {- ok: true,- status: 200,- json: async () => ({ data: { attributes: { ohlcv_list: [[Math.floor(Date.now() / 1000) - 60, 1, 1.1, 0.9, 1.05, 100]] } } }),- };+ return jsonResponse(200, {+ data: { attributes: { ohlcv_list: [[Math.floor(Date.now() / 1000) - 60, 1, 1.1, 0.9, 1.05, 100]] } },+ });}// Base58 alphabet (no 0/O/I/l) so a generated test mint always passes@@ -91,7 +95,7 @@ describe('geckoFetch retry (via the handler)', () => {vi.spyOn(globalThis, 'fetch').mockImplementation(async () => {call += 1;if (call === 1) return poolResponse();- if (call === 2) return { ok: false, status: 429, json: async () => ({}) };+ if (call === 2) return jsonResponse(429, {});return ohlcvResponse();});const res = makeRes();@@ -105,7 +109,7 @@ describe('geckoFetch retry (via the handler)', () => {vi.spyOn(globalThis, 'fetch').mockImplementation(async () => {call += 1;if (call === 1) return poolResponse();- if (call === 2) return { ok: false, status: 502, json: async () => ({}) };+ if (call === 2) return jsonResponse(502, {});return ohlcvResponse();});const res = makeRes();@@ -128,7 +132,7 @@ describe('geckoFetch retry (via the handler)', () => {});it('still 502s honestly when every attempt fails and there is no stale fallback', async () => {- vi.spyOn(globalThis, 'fetch').mockResolvedValue({ ok: false, status: 500, json: async () => ({}) });+ vi.spyOn(globalThis, 'fetch').mockImplementation(async () => jsonResponse(500, {}));const res = makeRes();await handler(makeReq(freshQuery()), res);expect(res.statusCode).toBe(502);@@ -138,8 +142,8 @@ describe('geckoFetch retry (via the handler)', () => {it('serves the honest no_market 404 when neither GeckoTerminal nor pump.fun has a market, without retrying', async () => {let poolCalls = 0;vi.spyOn(globalThis, 'fetch').mockImplementation(async (url) => {- if (String(url).includes('/pools?')) { poolCalls += 1; return { ok: false, status: 404, json: async () => ({}) }; }- if (String(url).includes('swap-api.pump.fun')) return { ok: false, status: 404, json: async () => ({}) };+ if (String(url).includes('/pools?')) { poolCalls += 1; return jsonResponse(404, {}); }+ if (String(url).includes('swap-api.pump.fun')) return jsonResponse(404, {});throw new Error('should never reach the ohlcv endpoint');});const res = makeRes();@@ -154,7 +158,7 @@ describe('pump.fun candle rung', () => {it('charts a young pump.fun coin GeckoTerminal has not indexed yet', async () => {const now = Math.floor(Date.now() / 1000);vi.spyOn(globalThis, 'fetch').mockImplementation(async (url) => {- if (String(url).includes('/pools?')) return { ok: false, status: 404, json: async () => ({}) };+ if (String(url).includes('/pools?')) return jsonResponse(404, {});if (String(url).includes('swap-api.pump.fun')) {return {ok: true,@@ -254,3 +258,35 @@ describe('in-flight de-duplication', () => {expect(ohlcvCalls).toBe(1);});});++// Production 2026-10-08: the Birdeye rung's own fallback (api/_lib/birdeye.js)+// had already asked GeckoTerminal for the mint's pools and been told "none".+// This handler then re-asked the identical URL milliseconds later, the shared+// Cloud Run egress drew 429s on it, the throttle read as an outage, and a coin+// with no market anywhere answered 502 instead of no_market.+describe('pool lookup shares the market resolver', () => {+ it('reuses the earlier "no pools" answer instead of re-asking a throttled GeckoTerminal', async () => {+ const { topPoolForToken } = await import('../../api/_lib/market/ohlcv.js');+ const mint = `${MINT.slice(0, 34)}${safeSuffix(77_001)}pump`;+ let poolCalls = 0;+ vi.spyOn(globalThis, 'fetch').mockImplementation(async (url) => {+ const u = String(url);+ if (u.includes('/pools?')) {+ poolCalls += 1;+ return poolCalls === 1 ? jsonResponse(200, { data: [] }) : jsonResponse(429, {});+ }+ if (u.includes('api.dexscreener.com')) return jsonResponse(200, { pairs: [] });+ if (u.includes('swap-api.pump.fun')) return jsonResponse(200, []);+ throw new Error(`unexpected upstream ${u}`);+ });++ // What the Birdeye rung's GeckoTerminal fallback does first in production.+ await expect(topPoolForToken(mint, 'solana')).rejects.toMatchObject({ status: 404 });++ const res = makeRes();+ await handler(makeReq(freshQuery(mint)), res);+ expect(res.statusCode).toBe(404);+ expect(getJson(res).error).toBe('no_market');+ expect(poolCalls).toBe(1);+ });+});