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(x402): wire x402-ring-leak-scan's declared maxDuration into wrapCron
nirholas5814b55856ee
diff --git a/api/cron/x402-ring-leak-scan.js b/api/cron/x402-ring-leak-scan.jsindex c5f72f54c..b1b567c6d 100644--- a/api/cron/x402-ring-leak-scan.js+++ b/api/cron/x402-ring-leak-scan.js@@ -76,7 +76,15 @@ const CANONICAL_USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';// with ledger activity is checked on the very next run.const LEASE_KEY = 'cron:x402-ring-leak-scan:lease';const LEASE_SECONDS = 9 * 60;-const RUN_BUDGET_MS = 200_000;+// 2026-10-24 incident: this file budgeted its own scan at 200s but never told+// wrapCron (api/_lib/http.js) about it, so wrapCron's own race fell back to its+// DEFAULT_CRON_MAX_DURATION_MS (120s) and answered 503 cron_timeout on every+// single invocation, always before the 200s internal budget was ever reached.+// vercel.json already declares 300s for this route; maxDuration below wires+// that same number into wrapCron so the external race matches the budget the+// scan was actually designed against.+export const maxDuration = 300;+export const RUN_BUDGET_MS = 200_000;const SCAN_CONCURRENCY = 4;// ── Pure classification (exported for tests) ──────────────────────────────────@@ -761,4 +769,4 @@ export default wrapCron(async (req, res) => {fee_cross_check: feeCheck,results,});-});+}, { maxDurationMs: maxDuration * 1000 });diff --git a/tests/x402-ring-leak-scan-run.test.js b/tests/x402-ring-leak-scan-run.test.jsindex 715dc8c3e..3d03da073 100644--- a/tests/x402-ring-leak-scan-run.test.js+++ b/tests/x402-ring-leak-scan-run.test.js@@ -11,6 +11,8 @@import { describe, it, expect, vi, beforeEach } from 'vitest';+import { DEFAULT_CRON_MAX_DURATION_MS } from '../api/_lib/http.js';+const lockHeld = { value: false };vi.mock('../api/_lib/cache.js', () => ({acquireLock: vi.fn(async () => !lockHeld.value),@@ -25,7 +27,22 @@ vi.mock('../api/_lib/db.js', () => ({}));vi.mock('../api/_lib/alerts.js', () => ({ sendOpsAlert: vi.fn(async () => {}) }));-const { scanWithinBudget, default: handler } = await import('../api/cron/x402-ring-leak-scan.js');+const { scanWithinBudget, maxDuration, RUN_BUDGET_MS, default: handler } = await import('../api/cron/x402-ring-leak-scan.js');++// 2026-10-24 production incident: every single invocation (100% over a 6h+// sample) answered 503 at ~120.0s, logging `[cron] x402-ring-leak-scan+// exceeded its 120000ms budget`. Root cause: the file never passed a+// `maxDurationMs` option to wrapCron, so http.js's wrapCron fell back to+// DEFAULT_CRON_MAX_DURATION_MS (120s) and raced every run against that, while+// the handler's own RUN_BUDGET_MS (200s) assumed it had until vercel.json's+// declared 300s maxDuration to work with. The external race always won first.+describe('cron timeout wiring', () => {+ it('declares a maxDuration that covers its own scan budget, so wrapCron does not truncate every run at the 120s default', () => {+ expect(maxDuration).toBeGreaterThan(0);+ expect(maxDuration * 1000).toBeGreaterThan(DEFAULT_CRON_MAX_DURATION_MS);+ expect(maxDuration * 1000).toBeGreaterThan(RUN_BUDGET_MS);+ });+});describe('scanWithinBudget', () => {it('stops starting wallets at the budget and reports how far it got', async () => {