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(pump): answer 204 for coins pump.fun has not indexed so widgets stop logging a 404 per card and stop re-asking the indexer

nirholas2f3f3202afd2
diff --git a/api/pump/[action].js b/api/pump/[action].js
index 9ac825e6c..dddcf8275 100644
--- a/api/pump/[action].js
+++ b/api/pump/[action].js
@@ -4185,6 +4185,17 @@ async function handleCoin(req, res) {
const mint = (url.searchParams.get('mint') || '').trim();
if (!MINT_RE.test(mint))
return error(res, 400, 'invalid_mint', 'mint must be a base58 address');
+ // `?miss=empty` is for callers with their own fallback (the coin-status
+ // widget reads the bonding curve next): an unindexed coin is an expected
+ // answer there, not an error, so it gets a 204 instead of a 404 that every
+ // browser prints to the console once per card on every refresh.
+ const softMiss = url.searchParams.get('miss') === 'empty';
+ const notFound = () => {
+ if (!softMiss) return error(res, 404, 'coin_not_found', 'no pump.fun coin for that mint');
+ res.setHeader('cache-control', 'public, max-age=60');
+ res.statusCode = 204;
+ return res.end();
+ };
const now = Date.now();
const hit = COIN_CACHE.get(mint);
@@ -4199,15 +4210,13 @@ async function handleCoin(req, res) {
// pump.fun returns 200 with an empty body for an unknown/unmigrated mint;
// pumpFetchJson reports that as ok:false with the 200 status. That is a
// real "coin not found", not an outage, so it never falls to last-good.
- if (r.status >= 200 && r.status < 300) return error(res, 404, 'coin_not_found', 'no pump.fun coin for that mint');
+ if (r.status >= 200 && r.status < 300) return notFound();
if (r.status === 0) return serveStaleCoin(res, mint, 504, 'upstream_timeout', 'pump.fun did not respond');
- if (r.status === 404) return error(res, 404, 'coin_not_found', 'no pump.fun coin for that mint');
+ if (r.status === 404) return notFound();
return serveStaleCoin(res, mint, 502, 'upstream_failed', `pump.fun returned ${r.status}`);
}
const parsed = r.body;
- if (!parsed || typeof parsed !== 'object') {
- return error(res, 404, 'coin_not_found', 'no pump.fun coin for that mint');
- }
+ if (!parsed || typeof parsed !== 'object') return notFound();
const [body] = repairCoinImages([parsed]);
COIN_CACHE.set(mint, { at: now, body });
cacheSet(coinLkgKey(mint), { at: now, body }, COIN_LKG_TTL_S).catch(() => {});
diff --git a/src/agent-wallet-hub/tabs/trade.js b/src/agent-wallet-hub/tabs/trade.js
index 22e210e75..811c93afd 100644
--- a/src/agent-wallet-hub/tabs/trade.js
+++ b/src/agent-wallet-hub/tabs/trade.js
@@ -310,8 +310,8 @@ registerWalletTab({
renderAll();
let meta = null;
try {
- const r = await fetch(`/api/pump/coin?mint=${encodeURIComponent(mint)}`, { headers: { accept: 'application/json' } });
- if (r.ok) meta = await r.json();
+ const r = await fetch(`/api/pump/coin?mint=${encodeURIComponent(mint)}&miss=empty`, { headers: { accept: 'application/json' } });
+ if (r.ok && r.status !== 204) meta = await r.json();
} catch { /* metadata is best-effort — the mint still trades */ }
if (destroyed || state.coin?.mint !== mint) return;
state.coin = {
diff --git a/src/communities.js b/src/communities.js
index 0ba3ba266..037ff666e 100644
--- a/src/communities.js
+++ b/src/communities.js
@@ -453,11 +453,14 @@ async function loadCoinProfile(mint, { force = false } = {}) {
let coin = null;
let loadFailed = false;
try {
- const r = await fetch(`/api/pump/coin?mint=${encodeURIComponent(mint)}`, { headers: { accept: 'application/json' } });
- if (r.ok) coin = await r.json();
- // A 5xx (or any non-404 non-ok) is a transient failure, not a real "missing
+ // `miss=empty`: a coin pump.fun has not indexed answers 204 (the empty
+ // state below) instead of a 404 the browser logs as an error.
+ const r = await fetch(`/api/pump/coin?mint=${encodeURIComponent(mint)}&miss=empty`, { headers: { accept: 'application/json' } });
+ if (r.status === 204) coin = null;
+ else if (r.ok) coin = await r.json();
+ // A 5xx (or any other non-ok) is a transient failure, not a real "missing
// coin" — track it so we offer a retry instead of a misleading "not found".
- else if (r.status !== 404) loadFailed = true;
+ else loadFailed = true;
} catch (err) {
loadFailed = true;
log.warn('[communities] coin profile', err?.message ?? err);
diff --git a/src/launch-detail.js b/src/launch-detail.js
index 7bb9e6003..2d74f5a1d 100644
--- a/src/launch-detail.js
+++ b/src/launch-detail.js
@@ -309,7 +309,10 @@ async function loadCoin() {
// Live pump.fun market — mainnet only (devnet has no pump.fun market data).
if (state.network !== 'mainnet') return null;
try {
- return await fetchJson(`/api/pump/coin?mint=${encodeURIComponent(state.mint)}`);
+ // `miss=empty`: an unindexed coin is an expected 204 (no market card),
+ // not a 404 in the console.
+ const r = await fetch(`/api/pump/coin?mint=${encodeURIComponent(state.mint)}&miss=empty`, { signal: AbortSignal.timeout(8000) });
+ return r.ok && r.status !== 204 ? await r.json() : null;
} catch {
return null;
}
diff --git a/src/mission-control/focus.js b/src/mission-control/focus.js
index f8e614008..94a4f84bb 100644
--- a/src/mission-control/focus.js
+++ b/src/mission-control/focus.js
@@ -119,7 +119,9 @@ export function createFocusPane({ store, bus, enrich, mount }) {
async function fetchCoin(mint, { retry = true } = {}) {
clearTimeout(coinRetryTimer);
try {
- const r = await fetch(`/api/pump/coin?mint=${encodeURIComponent(mint)}`, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(10_000) });
+ const r = await fetch(`/api/pump/coin?mint=${encodeURIComponent(mint)}&miss=empty`, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(10_000) });
+ // 204: pump.fun has not indexed this mint. Expected, not an error.
+ if (r.status === 204) return null;
if (r.ok) return await r.json();
if (retry && r.status >= 500) {
const after = Math.min(60, Math.max(5, Number(r.headers.get('retry-after')) || 15)) * 1000;
diff --git a/src/pump/coin-status-card.curve.dom.test.js b/src/pump/coin-status-card.curve.dom.test.js
index d9b03cada..926a8d2c9 100644
--- a/src/pump/coin-status-card.curve.dom.test.js
+++ b/src/pump/coin-status-card.curve.dom.test.js
@@ -169,4 +169,33 @@ describe('mountCoinStatus: mainnet indexer fallback', () => {
expect(called.some((u) => u.includes('/api/pump/curve'))).toBe(false);
handle.destroy();
});
+
+ it('asks for a soft miss, then stops re-asking the indexer for an unindexed coin', async () => {
+ // Its own mint: the unindexed set is module-wide, and the cases above must
+ // still reach the indexer for MINT.
+ const mint = '3wsUnindexed1111111111111111111111111111111';
+ const noContent = () => () => Promise.resolve({ ok: true, status: 204, json: () => Promise.reject(new SyntaxError('empty body')) });
+ const fetchMock = routedFetch([
+ ['/api/pump/coin', noContent()],
+ ['/api/pump/curve', ok(curveBody({ mint, network: 'mainnet' }))],
+ ['jup.ag', ok({ So11111111111111111111111111111111111111112: { usdPrice: 200 } })],
+ ]);
+ vi.stubGlobal('fetch', fetchMock);
+ vi.useFakeTimers({ shouldAdvanceTime: true });
+
+ const handle = mountCoinStatus(container, mint, { variant: 'chip', refreshMs: 1000 });
+ await vi.waitFor(() => expect(container.querySelector('.csc-mcap')).toBeTruthy());
+ expect(container.querySelector('.csc-mcap').textContent).toBe('$6.4K');
+
+ const coinCalls = () => fetchMock.mock.calls.map(([u]) => String(u)).filter((u) => u.includes('/api/pump/coin'));
+ expect(coinCalls()).toHaveLength(1);
+ expect(coinCalls()[0]).toContain('miss=empty');
+
+ const curveCalls = () => fetchMock.mock.calls.filter(([u]) => String(u).includes('/api/pump/curve')).length;
+ const before = curveCalls();
+ await vi.advanceTimersByTimeAsync(1000);
+ await vi.waitFor(() => expect(curveCalls()).toBeGreaterThan(before));
+ expect(coinCalls()).toHaveLength(1);
+ handle.destroy();
+ });
});
diff --git a/src/pump/coin-status-card.js b/src/pump/coin-status-card.js
index b74ed18c9..8cc0cc5f7 100644
--- a/src/pump/coin-status-card.js
+++ b/src/pump/coin-status-card.js
@@ -41,6 +41,12 @@ const COIN_ENDPOINT = '/api/pump/coin';
const CURVE_ENDPOINT = '/api/pump/curve';
const ORACLE_ENDPOINT = '/api/oracle/coin';
const DEFAULT_REFRESH_MS = 30_000;
+// Mints pump.fun's indexer answered "unknown" for (204 under `miss=empty`).
+// Some live three.ws launches never appear in that index, so asking again on
+// every 30 s refresh only repeats a known miss; the curve read is the source
+// for them for the rest of the page's life. Shared across widget instances so
+// two cards for one coin do not each re-learn it.
+const UNINDEXED_MINTS = new Set();
// pump.fun bonding curves complete (graduate) around a ~$69k USD market cap;
// the same constant the agent token widget uses for its graduation gauge.
const GRADUATION_CAP_USD = 69_000;
@@ -736,12 +742,15 @@ export function mountCoinStatus(container, mint, opts = {}) {
lastCoin = await loadFromCurve(sig);
} else {
let indexed = null;
- try {
- const r = await fetch(`${COIN_ENDPOINT}?mint=${encodeURIComponent(mint)}`, { signal: sig });
- if (r.ok) indexed = mapCoin(await r.json(), mint);
- } catch (err) {
- // A cancelled load is not an indexer failure, so let it unwind.
- if (err?.name === 'AbortError') throw err;
+ if (!UNINDEXED_MINTS.has(mint)) {
+ try {
+ const r = await fetch(`${COIN_ENDPOINT}?mint=${encodeURIComponent(mint)}&miss=empty`, { signal: sig });
+ if (r.status === 204) UNINDEXED_MINTS.add(mint);
+ else if (r.ok) indexed = mapCoin(await r.json(), mint);
+ } catch (err) {
+ // A cancelled load is not an indexer failure, so let it unwind.
+ if (err?.name === 'AbortError') throw err;
+ }
}
// The indexer does not know this coin, or could not be reached. The
// chain always knows: read the curve rather than showing "unavailable"