From ef7a8a1c6395c09239c12e3208ebcbe98d2a2c63 Mon Sep 17 00:00:00 2001 From: Greg Soucy Date: Fri, 20 Mar 2026 16:51:31 -0400 Subject: [PATCH] [runtime] short-circuit cached-only /verify schema checks early Why: cold schema compiles were delaying /verify responses long enough to trigger client aborts instead of returning the documented 202 warmup response. Contract impact: none --- server.mjs | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/server.mjs b/server.mjs index d5af7e5..6d72149 100644 --- a/server.mjs +++ b/server.mjs @@ -1731,8 +1731,31 @@ app.post("/verify", async (req, res) => { const proof = receipt?.metadata?.proof; const proofCanonical = String(proof?.canonical_id || proof?.canonical || ""); + const verb = String(receipt?.x402?.verb || "").trim(); const runtimeCoreReceipt = normalizeReceiptForRuntimeCoreVerify(receipt); + if (wantSchema && VERIFY_SCHEMA_CACHED_ONLY && !hasValidatorCached(verb)) { + warmQueue.add(verb); + startWarmWorker(); + + return res.status(202).json({ + ok: false, + checks: { + schema_valid: false, + hash_matches: null, + signature_valid: null, + ens_match: wantEns ? null : null, + }, + errors: { + schema_errors: [{ message: "validator_not_warmed_yet" }], + signature_error: null, + }, + reason: "validator_not_warmed_yet", + retry_after_ms: 1000, + ...instancePayload(), + }); + } + const verifyLogic = async () => { if (!proof?.signature_b64 || !proof?.hash_sha256) { return res.status(400).json({ @@ -1862,33 +1885,9 @@ app.post("/verify", async (req, res) => { if (wantSchema) { schemaOk = false; - const verb = String(receipt?.x402?.verb || "").trim(); if (!verb) { schemaErrors = [{ message: "missing receipt.x402.verb" }]; - } else if (VERIFY_SCHEMA_CACHED_ONLY && !hasValidatorCached(verb)) { - warmQueue.add(verb); - startWarmWorker(); - - return res.status(202).json({ - ok: false, - checks: { - schema_valid: false, - hash_matches: hashMatches, - signature_valid: signatureValid, - ens_match: wantEns ? true : null, - }, - values: { - verb: receipt?.x402?.verb ?? null, - signer_id: proof?.signer_id ?? null, - pubkey_source: pubSrc, - claimed_hash: proof?.hash_sha256 ?? null, - ens: ensExpect, - }, - errors: { schema_errors: [{ message: "validator_not_warmed_yet" }], signature_error: sigErr }, - retry_after_ms: 1000, - ...instancePayload(), - }); } else { try { const validate = VERIFY_SCHEMA_CACHED_ONLY ? validatorCache.get(verb)?.validate : await getValidatorForVerb(verb);