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(tests): hoist the facilitator-log resolver list out of its temporal dead zone

nirholasc82ddabc2775
diff --git a/tests/api/x402-facilitator-log-durable.test.js b/tests/api/x402-facilitator-log-durable.test.js
index 17b18dd3c..be454930d 100644
--- a/tests/api/x402-facilitator-log-durable.test.js
+++ b/tests/api/x402-facilitator-log-durable.test.js
@@ -19,7 +19,12 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
// SELECT → [] (no prior credit for this signature); INSERT → one row (the claim
// is ours). That is the real granted-credit path, which is what the assertion
// below is about.
-let pendingResolvers = [];
+// Hoisted alongside the vi.mock registrations: the db.js factory below runs
+// when the handler import (itself hoisted above this module body) first loads
+// db.js, so a plain module-level `let` was still in its temporal dead zone
+// under full-suite load and the factory threw "Cannot access 'pendingResolvers'
+// before initialization".
+const pendingResolvers = vi.hoisted(() => []);
function rowsFor(query) {
return /INSERT/i.test(query) ? [{ id: 1 }] : [];
}
@@ -59,7 +64,7 @@ const REQ_BODY = {
paymentRequirements: { network: 'solana:x', payTo: 'PAYTO', asset: 'MINT', amount: '10000' },
};
-beforeEach(() => { pendingResolvers = []; });
+beforeEach(() => { pendingResolvers.length = 0; });
describe('self-facilitator log durability', () => {
it('verify does not respond until the audit-log write resolves', async () => {