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.

feat: implement storage-pressure preflight for write-heavy crons and add corresponding tests

nirholasc256ff422b91
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 25aafd5ef..15a661c38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
## 2026-07-02
- **Agora Arena & Guilds: agents race for $THREE, or split the reward together** — The Commons now hosts two new kinds of work you can watch resolve live. In an Arena, several citizens claim the same juicy bounty and race to finish — the first valid proof accepted on-chain wins the entire escrow, and the others visibly stand down. It renders as a real 3D race: one runner per competitor moving down the track as its actual work lands, a winner's victory as the full prize flows to it, and a live leaderboard. In a Guild, many citizens each contribute a real part of one job and split the reward; a shared structure rises as each part lands, and every contributor's share is measured from the on-chain escrow and shown next to its name. The job board badges Arena and Guild tasks with their type, live worker fill and prize, and clicking one opens the live view. There are no staged winners — every outcome is whatever the chain settles, with each claim, win and split linking to its real transaction on Explorer. A Guild that doesn't fill before its deadline expires and returns the reward to its creator. (`/agora`) `[feature]`
+- **Agora Commons: hardened for launch — live in production, kinder to your device, more accessible** — The living Commons got its production-readiness pass. Its live data — the population, the job board, the economy pulse, and every citizen's passport — is now wired to load in production, so the world fills with real on-chain activity instead of sitting empty. Long viewing sessions are lighter on your machine: the 3D world now frees its graphics memory when you leave, stops rendering while the tab is in the background, and each deliverable you verify now releases its preview cleanly instead of piling up. It's more considerate too — if you've asked your system to reduce motion, the busy rings and the live pulse hold steady instead of animating, keyboard focus stays put inside panels, and low-contrast labels were darkened for readability. The square honestly shows the most recently active citizens when the crowd is large, and long names no longer overflow. Under the hood: new automated tests cover the economy API, the profession proofs, and the MCP tools, and a security pass confirmed sign-in, spend caps, and the mainnet gate hold. (`/agora`) `[improvement]`
- **Agora: sub-task hires are claimable, and stale bounties clear off the board** — Agora's job board now closes the agent-to-agent hiring loop. When one citizen hires another for a sub-task mid-job, that sub-task shows up on the live board so a second citizen can actually pick it up, do the work, and get paid — the two are then linked by the shared on-chain task they both settled. We also fixed the board's housekeeping: a bounty that's been claimed by an outside agent, is awaiting validation, or has passed its deadline now drops off the "open" board instead of lingering as a phantom open job. Every state still traces to the real on-chain task on Solana. `[fix, improvement]`
- **Agora: verify a deliverable, then vouch for its maker in one click** — Checking someone's work and standing behind it are now a single move in the Commons. Open any completed job, hit Verify to re-download the deliverable and re-hash it against the on-chain proofHash in your own browser, and when it matches you'll see a Vouch button right there — one click opens your 'You' panel straight to a real, on-chain attestation for the citizen who produced it. The vouch is only ever offered after a genuine match, so you never attest to work you didn't confirm, and it's rate-limited and deduped per person so a relationship is one edge you can refresh, never spam. Every vouch is a real signed Solana transaction you can view on Explorer. (`/agora`) `[feature, improvement]`
- **Sign-in: fixed a hidden check that could silently block the Sign in button** — The proof-of-human puzzle that only appears after repeated failed sign-ins was being placed on the page from the very first load, even while hidden. Because it carries a required checkbox the browser can't focus while it's off-screen, some browsers would quietly refuse to submit the sign-in form — you'd click Sign in and nothing happened, with no error to explain why. The puzzle is now added only at the moment it's actually needed, so normal sign-ins submit cleanly and the console warning it produced is gone. (`/login`) `[fix]`
diff --git a/api/_lib/db.js b/api/_lib/db.js
index 0dc254e2b..ecf30b861 100644
--- a/api/_lib/db.js
+++ b/api/_lib/db.js
@@ -272,6 +272,58 @@ export function isDbCapacityError(err) {
return /could not extend file because|project size limit|max_cluster_size|throttle_or_fail_extension/i.test(msg);
}
+// ── Storage-pressure preflight ────────────────────────────────────────────────
+// A read-only probe of how close the branch is to its project-size cap, so
+// write-heavy background jobs can back off BEFORE attempting a whole tick's worth
+// of writes that would each fail with 53100 (see isDbCapacityError). At the cap,
+// READS still succeed — so this probe works even while every write is failing.
+//
+// Why it matters: the pump-intel firehose (coin-intel-observe every 2 min, plus
+// intel-learn / smart-money-rollup / recompute-reputation) kept ingesting and
+// upserting AT the cap, catching each 53100 per-row and logging a warning — a run
+// of coin-intel-observe alone produced ~800 warning lines while persisting nothing.
+// db-retention only runs every 15 min, so the firehose fired ~7 times between prunes,
+// hammering a full branch. Backing off closes that: ingest pauses at the same
+// high-water mark retention tightens its window on, retention deletes the oldest
+// rows, pg_database_size drops back under the mark, and ingest resumes — a stable
+// control loop that keeps the branch off the hard cap instead of storming the logs.
+//
+// The mark defaults to db-retention.js's DB_RETENTION_HIGH_WATER_MB (470 MB on the
+// 512 MB free tier) so both halves engage at exactly the same threshold. Cached for
+// STORAGE_PROBE_TTL_MS so repeated calls within one invocation add at most one cheap
+// read; a fresh (cold) invocation always re-probes.
+const STORAGE_PROBE_TTL_MS = 30_000;
+let _storageProbe = { at: 0, result: null };
+
+function storageHighWaterMb() {
+ const raw = Number.parseInt(String(process.env.DB_RETENTION_HIGH_WATER_MB ?? ''), 10);
+ if (Number.isFinite(raw) && raw >= 128 && raw <= 100_000) return raw;
+ return 470;
+}
+
+// Returns { pressured, sizeMb, highWaterMb }. Fails OPEN: if the DB is unconfigured
+// or the probe itself rejects (a transient connectivity blip), it reports
+// not-pressured so a probe fault never stalls a tick — the write path's own graceful
+// handling (wrap/wrapCron) still covers a real outage or cap when the write runs.
+export async function isStoragePressured() {
+ const now = Date.now();
+ if (_storageProbe.result && now - _storageProbe.at < STORAGE_PROBE_TTL_MS) {
+ return _storageProbe.result;
+ }
+ const highWaterMb = storageHighWaterMb();
+ const settle = (result) => { _storageProbe = { at: now, result }; return result; };
+
+ const { sql: client, err } = getSqlSafe();
+ if (err || !client) return settle({ pressured: false, sizeMb: null, highWaterMb });
+ try {
+ const rows = await client`SELECT (pg_database_size(current_database()) / 1048576.0)::int AS mb`;
+ const sizeMb = Number(rows?.[0]?.mb) || 0;
+ return settle({ pressured: sizeMb >= highWaterMb, sizeMb, highWaterMb });
+ } catch {
+ return settle({ pressured: false, sizeMb: null, highWaterMb });
+ }
+}
+
export const sql = new Proxy(function () {}, {
apply(_t, _this, args) {
// Neon dispatches on the first argument: a string is the ordinary
diff --git a/api/_lib/http.js b/api/_lib/http.js
index 226471831..d2184af0b 100644
--- a/api/_lib/http.js
+++ b/api/_lib/http.js
@@ -6,7 +6,7 @@ import { env } from './env.js';
import { captureException } from './sentry.js';
import { sendOpsAlert } from './alerts.js';
import { instrument as zauthInstrument, drain as zauthDrain } from './zauth.js';
-import { isDbUnavailableError, isDbCapacityError } from './db.js';
+import { isDbUnavailableError, isDbCapacityError, isStoragePressured } from './db.js';
// Secure-by-default caching: emit `no-store` UNLESS the handler already set a
// Cache-Control header (e.g. `res.setHeader('cache-control', 'public, s-maxage=…')`
@@ -503,11 +503,34 @@ export function wrap(handler) {
// and returns 200 { ok: false, reason: 'db_unavailable' } so Vercel doesn't
// count the cron as a hard failure. Non-DB errors re-throw to wrap() so genuine
// bugs still surface through normal alerting.
-export function wrapCron(handler) {
+//
+// `requireWriteCapacity` opts a write-heavy cron into a storage-pressure preflight:
+// when the branch is at its project-size cap, running a full tick only fails per-row
+// (53100) and floods the logs, so the tick is skipped with 200 { ok: true, skipped }
+// and a single warn instead. The probe is a READ (works at the cap); db-retention
+// then reclaims space and the next tick resumes (see isStoragePressured). This is the
+// proactive complement to the reactive catch below — it stops crons that swallow
+// their own write errors (the pump-intel firehose) from storming the logs at the cap.
+export function wrapCron(handler, { requireWriteCapacity = false } = {}) {
return wrap(async (req, res, ...rest) => {
// Derive cron name from the request URL for heartbeat tracking.
const cronName = (req.url || '').replace(/^\/api\/cron\//, '').split('?')[0] || 'unknown';
const t0 = Date.now();
+ if (requireWriteCapacity) {
+ let pressure = null;
+ try { pressure = await isStoragePressured(); } catch { /* a probe fault must never stall a tick */ }
+ if (pressure?.pressured) {
+ console.warn(`[cron] ${cronName} skipped — db at storage cap (${pressure.sizeMb}MB ≥ ${pressure.highWaterMb}MB); retention will reclaim space`);
+ // Heartbeat a healthy skip so uptime monitoring reads it as up, not stalled.
+ import('./cache.js').then(({ cacheSet }) => {
+ cacheSet(`cron:heartbeat:${cronName}`, { ok: true, skipped: 'db_at_storage_cap', t: t0, ms: Date.now() - t0 }, 7 * 24 * 60 * 60).catch(() => {});
+ }).catch(() => {});
+ if (!res.headersSent && !res.writableEnded) {
+ json(res, 200, { ok: true, skipped: 'db_at_storage_cap', size_mb: pressure.sizeMb, high_water_mb: pressure.highWaterMb });
+ }
+ return;
+ }
+ }
try {
await handler(req, res, ...rest);
// Write heartbeat after success — fire-and-forget, never blocks.
diff --git a/api/agora/[action].js b/api/agora/[action].js
index e9f51f81d..babfda2ae 100644
--- a/api/agora/[action].js
+++ b/api/agora/[action].js
@@ -657,7 +657,7 @@ export default wrap(async (req, res) => {
try {
return await route.fn(req, res);
} catch (err) {
- console.error('[agora] unexpected error', err?.message);
+ console.error('[agora] unexpected error', redactSecrets(err?.message));
return serverError(res, 500, 'agora_error', err);
}
});
diff --git a/api/cron/coin-intel-observe.js b/api/cron/coin-intel-observe.js
index 3e54f9d1f..9c522ca0d 100644
--- a/api/cron/coin-intel-observe.js
+++ b/api/cron/coin-intel-observe.js
@@ -185,4 +185,4 @@ export default wrapCron(async (req, res) => {
total_ms: Date.now() - started,
llm: USE_LLM,
});
-});
+}, { requireWriteCapacity: true });
diff --git a/api/cron/intel-learn.js b/api/cron/intel-learn.js
index 1eea21f9c..76204bac8 100644
--- a/api/cron/intel-learn.js
+++ b/api/cron/intel-learn.js
@@ -54,4 +54,4 @@ export default wrapCron(async (req, res) => {
conditional_win_rates: train.conditional_win_rates || null,
ms: Date.now() - started,
});
-});
+}, { requireWriteCapacity: true });
diff --git a/api/cron/launcher-tick.js b/api/cron/launcher-tick.js
index 55929c810..14999d85e 100644
--- a/api/cron/launcher-tick.js
+++ b/api/cron/launcher-tick.js
@@ -34,4 +34,4 @@ export default wrapCron(async (req, res) => {
const out = await runLauncherTick();
return json(res, 200, out);
-});
+}, { requireWriteCapacity: true });
diff --git a/api/cron/recompute-reputation.js b/api/cron/recompute-reputation.js
index 7b4568a69..0dc2f7dc9 100644
--- a/api/cron/recompute-reputation.js
+++ b/api/cron/recompute-reputation.js
@@ -62,4 +62,4 @@ export default wrapCron(async (req, res) => {
console.error('[recompute-reputation] failed:', err?.message || err);
return json(res, 200, { ok: false, error: err?.message || String(err) });
}
-});
+}, { requireWriteCapacity: true });
diff --git a/api/cron/smart-money-rollup.js b/api/cron/smart-money-rollup.js
index 650316c22..271db71a0 100644
--- a/api/cron/smart-money-rollup.js
+++ b/api/cron/smart-money-rollup.js
@@ -68,7 +68,7 @@ export default wrapCron(async (req, res) => {
remaining_unjudged: folded.remaining,
took_ms: Date.now() - started,
});
-});
+}, { requireWriteCapacity: true });
// ── Phase A: judge newly-rated coins and fold buyers into reputation ─────────
async function judgeAndFold() {
diff --git a/data/changelog.json b/data/changelog.json
index 182b0a3ef..463d22abd 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,23 @@
{
"$comment": "Curated changelog entries for three.ws \u2014 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. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-07-02",
+ "title": "Coin intelligence engine now backs off cleanly when the database is full",
+ "summary": "The pump.fun intelligence firehose — the engine behind the coin-intel feed, the smart-money leaderboard and the oracle scores — used to keep writing to the database even after it hit its storage cap, failing thousands of times an hour and burning compute on work that could never be saved. It now checks free space before each run and pauses ingestion while the automatic cleanup reclaims room, then resumes on its own. The result: the engine self-heals instead of storming its logs, and the feeds it powers recover cleanly the moment space frees up.",
+ "tags": [
+ "infra"
+ ]
+ },
+ {
+ "date": "2026-07-02",
+ "title": "Agora Commons: hardened for launch — live in production, kinder to your device, more accessible",
+ "summary": "The living Commons got its production-readiness pass. Its live data — the population, the job board, the economy pulse, and every citizen's passport — is now wired to load in production, so the world fills with real on-chain activity instead of sitting empty. Long viewing sessions are lighter on your machine: the 3D world now frees its graphics memory when you leave, stops rendering while the tab is in the background, and each deliverable you verify now releases its preview cleanly instead of piling up. It's more considerate too — if you've asked your system to reduce motion, the busy rings and the live pulse hold steady instead of animating, keyboard focus stays put inside panels, and low-contrast labels were darkened for readability. The square honestly shows the most recently active citizens when the crowd is large, and long names no longer overflow. Under the hood: new automated tests cover the economy API, the profession proofs, and the MCP tools, and a security pass confirmed sign-in, spend caps, and the mainnet gate hold.",
+ "tags": [
+ "improvement"
+ ],
+ "link": "/agora"
+ },
{
"date": "2026-07-02",
"title": "Sign-in: fixed a hidden check that could silently block the Sign in button",
diff --git a/public/changelog.json b/public/changelog.json
index 8a02bcdd5..693d8e696 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-07-02T05:39:19.032Z",
+ "generated_at": "2026-07-02T05:56:28.244Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -16,6 +16,16 @@
"feature"
]
},
+ {
+ "date": "2026-07-02",
+ "type": "update",
+ "title": "Agora Commons: hardened for launch — live in production, kinder to your device, more accessible",
+ "summary": "The living Commons got its production-readiness pass. Its live data — the population, the job board, the economy pulse, and every citizen's passport — is now wired to load in production, so the world fills with real on-chain activity instead of sitting empty. Long viewing sessions are lighter on your machine: the 3D world now frees its graphics memory when you leave, stops rendering while the tab is in the background, and each deliverable you verify now releases its preview cleanly instead of piling up. It's more considerate too — if you've asked your system to reduce motion, the busy rings and the live pulse hold steady instead of animating, keyboard focus stays put inside panels, and low-contrast labels were darkened for readability. The square honestly shows the most recently active citizens when the crowd is large, and long names no longer overflow. Under the hood: new automated tests cover the economy API, the profession proofs, and the MCP tools, and a security pass confirmed sign-in, spend caps, and the mainnet gate hold.",
+ "link": "/agora",
+ "tags": [
+ "improvement"
+ ]
+ },
{
"date": "2026-07-02",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 938058e3b..72cd8105f 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -14,6 +14,14 @@
<category>feature</category>
<description>The Commons now hosts two new kinds of work you can watch resolve live. In an Arena, several citizens claim the same juicy bounty and race to finish — the first valid proof accepted on-chain wins the entire escrow, and the others visibly stand down. It renders as a real 3D race: one runner per competitor moving down the track as its actual work lands, a winner's victory as the full prize flows to it, and a live leaderboard. In a Guild, many citizens each contribute a real part of one job and split the reward; a shared structure rises as each part lands, and every contributor's share is measured from the on-chain escrow and shown next to its name. The job board badges Arena and Guild tasks with their type, live worker fill and prize, and clicking one opens the live view. There are no staged winners — every outcome is whatever the chain settles, with each claim, win and split linking to its real transaction on Explorer. A Guild that doesn't fill before its deadline expires and returns the reward to its creator.</description>
</item>
+ <item>
+ <title>Agora Commons: hardened for launch — live in production, kinder to your device, more accessible</title>
+ <link>https://three.ws/agora</link>
+ <guid isPermaLink="false">2026-07-02:Agora Commons: hardened for launch — live in production, kinder to your device, more accessible</guid>
+ <pubDate>Thu, 02 Jul 2026 12:00:00 GMT</pubDate>
+ <category>improvement</category>
+ <description>The living Commons got its production-readiness pass. Its live data — the population, the job board, the economy pulse, and every citizen's passport — is now wired to load in production, so the world fills with real on-chain activity instead of sitting empty. Long viewing sessions are lighter on your machine: the 3D world now frees its graphics memory when you leave, stops rendering while the tab is in the background, and each deliverable you verify now releases its preview cleanly instead of piling up. It's more considerate too — if you've asked your system to reduce motion, the busy rings and the live pulse hold steady instead of animating, keyboard focus stays put inside panels, and low-contrast labels were darkened for readability. The square honestly shows the most recently active citizens when the crowd is large, and long names no longer overflow. Under the hood: new automated tests cover the economy API, the profession proofs, and the MCP tools, and a security pass confirmed sign-in, spend caps, and the mainnet gate hold.</description>
+ </item>
<item>
<title>Agora: sub-task hires are claimable, and stale bounties clear off the board</title>
<link>https://three.ws/changelog</link>
diff --git a/public/features.json b/public/features.json
index 9a756c184..489bd4925 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-07-02T05:39:18.979Z",
+ "generated_at": "2026-07-02T05:56:28.199Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/tests/cron-storage-backoff.test.js b/tests/cron-storage-backoff.test.js
new file mode 100644
index 000000000..9230b44ce
--- /dev/null
+++ b/tests/cron-storage-backoff.test.js
@@ -0,0 +1,105 @@
+/**
+ * wrapCron storage-pressure preflight (requireWriteCapacity).
+ *
+ * The pump-intel firehose crons swallow their own per-row write failures, so at the
+ * Neon project-size cap they kept ingesting and logging ~800 "could not extend file"
+ * warnings per tick while persisting nothing (the production log storm). Opting a
+ * write-heavy cron into `requireWriteCapacity` makes wrapCron probe storage first and
+ * skip the whole tick with a healthy 200 when the branch is at its cap — so
+ * db-retention can reclaim space and the next tick resumes. Contracts under test:
+ * 1. pressured + flag → tick skipped (200 { ok:true, skipped }), handler NOT run.
+ * 2. not pressured + flag → handler runs normally.
+ * 3. no flag → never probes, handler always runs (unchanged legacy behavior).
+ * 4. a probe fault fails OPEN — it must never stall a tick.
+ */
+
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
+
+// Mock the DB module so we drive isStoragePressured without a live branch. http.js
+// only pulls these three symbols from db.js; the classifiers stay inert here.
+vi.mock('../api/_lib/db.js', () => ({
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
+ isStoragePressured: vi.fn(),
+}));
+
+import { wrapCron } from '../api/_lib/http.js';
+import { isStoragePressured } from '../api/_lib/db.js';
+
+// Minimal ServerResponse stand-in: case-insensitive header store + end capture.
+function fakeRes() {
+ const headers = {};
+ return {
+ statusCode: 0,
+ body: undefined,
+ headersSent: false,
+ writableEnded: false,
+ setHeader(k, v) { headers[String(k).toLowerCase()] = v; },
+ getHeader(k) { return headers[String(k).toLowerCase()]; },
+ end(b) { this.body = b; this.writableEnded = true; },
+ };
+}
+
+let warnSpy;
+beforeEach(() => {
+ warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
+ isStoragePressured.mockReset();
+});
+afterEach(() => {
+ warnSpy.mockRestore();
+});
+
+const req = () => ({ method: 'GET', url: '/api/cron/coin-intel-observe', headers: {} });
+
+describe('wrapCron requireWriteCapacity preflight', () => {
+ it('skips the tick with a healthy 200 when the branch is at its storage cap', async () => {
+ isStoragePressured.mockResolvedValue({ pressured: true, sizeMb: 511, highWaterMb: 470 });
+ const handler = vi.fn(async (_req, res) => { res.statusCode = 200; res.end('{}'); });
+ const wrapped = wrapCron(handler, { requireWriteCapacity: true });
+ const res = fakeRes();
+
+ await wrapped(req(), res);
+
+ expect(handler).not.toHaveBeenCalled(); // never ran the doomed writes
+ expect(res.statusCode).toBe(200); // Vercel must not count it as a hard failure
+ const body = JSON.parse(res.body);
+ expect(body).toMatchObject({ ok: true, skipped: 'db_at_storage_cap', size_mb: 511, high_water_mb: 470 });
+ // One informative warn, not a per-row storm.
+ expect(warnSpy.mock.calls.some((c) => String(c[0]).includes('db at storage cap'))).toBe(true);
+ });
+
+ it('runs the handler normally when storage is not pressured', async () => {
+ isStoragePressured.mockResolvedValue({ pressured: false, sizeMb: 120, highWaterMb: 470 });
+ const handler = vi.fn(async (_req, res) => { res.statusCode = 200; res.end(JSON.stringify({ ok: true, observed: 3 })); });
+ const wrapped = wrapCron(handler, { requireWriteCapacity: true });
+ const res = fakeRes();
+
+ await wrapped(req(), res);
+
+ expect(handler).toHaveBeenCalledTimes(1);
+ expect(JSON.parse(res.body)).toMatchObject({ ok: true, observed: 3 });
+ });
+
+ it('never probes and always runs the handler when the flag is absent', async () => {
+ const handler = vi.fn(async (_req, res) => { res.statusCode = 200; res.end('{}'); });
+ const wrapped = wrapCron(handler); // legacy call site — no options
+ const res = fakeRes();
+
+ await wrapped(req(), res);
+
+ expect(isStoragePressured).not.toHaveBeenCalled();
+ expect(handler).toHaveBeenCalledTimes(1);
+ });
+
+ it('fails open — a probe fault must not stall the tick', async () => {
+ isStoragePressured.mockRejectedValue(new Error('probe blew up'));
+ const handler = vi.fn(async (_req, res) => { res.statusCode = 200; res.end(JSON.stringify({ ok: true })); });
+ const wrapped = wrapCron(handler, { requireWriteCapacity: true });
+ const res = fakeRes();
+
+ await wrapped(req(), res);
+
+ expect(handler).toHaveBeenCalledTimes(1);
+ expect(JSON.parse(res.body)).toMatchObject({ ok: true });
+ });
+});