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: export isNonActionableNoise function and add tests for filtering injected wallet-provider RPC noise

qbdz5077c6df234f
diff --git a/api/client-errors.js b/api/client-errors.js
index 53f4cc740..908486237 100644
--- a/api/client-errors.js
+++ b/api/client-errors.js
@@ -74,7 +74,7 @@ const PROP_ACCESS_TYPEERROR =
// focused on genuine first-party faults. Clients running a freshly-cached
// error-reporter.js already filter these locally; this is the server-side
// backstop for the long tail of clients holding an older cached reporter.
-function isNonActionableNoise(event) {
+export function isNonActionableNoise(event) {
if (event.type !== 'error' && event.type !== 'unhandledrejection') return false;
const msg = event.message || '';
// Cross-origin "Script error." — the browser strips every detail (stack,
diff --git a/tests/client-errors-noise.test.js b/tests/client-errors-noise.test.js
new file mode 100644
index 000000000..2e3075e3b
--- /dev/null
+++ b/tests/client-errors-noise.test.js
@@ -0,0 +1,43 @@
+import { describe, it, expect } from 'vitest';
+import { isNonActionableNoise } from '../api/client-errors.js';
+
+const ev = (over) => ({ type: 'unhandledrejection', name: 'Object', message: '', stack: '', ...over });
+
+describe('isNonActionableNoise — injected wallet-provider RPC noise', () => {
+ // The exact signature seen in production: an injected EVM wallet rejects
+ // window.ethereum.request() with EIP-1474 "Internal JSON-RPC error." as a plain
+ // object (caught name "Object"), surfacing as an unhandledrejection on pages
+ // that merely co-exist with a wallet extension (e.g. /trending).
+ it('drops "Internal JSON-RPC error." with and without trailing period', () => {
+ expect(isNonActionableNoise(ev({ message: 'Internal JSON-RPC error.' }))).toBe(true);
+ expect(isNonActionableNoise(ev({ message: 'Internal JSON-RPC error' }))).toBe(true);
+ });
+
+ it('drops wallet user-cancellation messages (not faults)', () => {
+ expect(isNonActionableNoise(ev({ message: 'User rejected the request.' }))).toBe(true);
+ expect(isNonActionableNoise(ev({ message: 'User denied transaction signature' }))).toBe(true);
+ expect(isNonActionableNoise(ev({ message: "Already processing eth_requestAccounts. Please wait." }))).toBe(true);
+ expect(isNonActionableNoise(ev({ message: "Request of type 'wallet_switchEthereumChain' already pending" }))).toBe(true);
+ });
+
+ it('drops the same wallet noise reported as a top-level error event', () => {
+ expect(isNonActionableNoise(ev({ type: 'error', message: 'Internal JSON-RPC error.' }))).toBe(true);
+ });
+
+ it('keeps genuine first-party faults that merely contain similar words', () => {
+ expect(isNonActionableNoise(ev({ message: 'Internal server error' }))).toBe(false);
+ expect(isNonActionableNoise(ev({ message: 'An internal error occurred while rendering' }))).toBe(false);
+ expect(isNonActionableNoise(ev({ message: 'Failed to load avatar' }))).toBe(false);
+ expect(isNonActionableNoise(ev({ type: 'error', name: 'TypeError', message: 'x is not a function' }))).toBe(false);
+ });
+
+ it('still drops the pre-existing noise classes', () => {
+ expect(isNonActionableNoise(ev({ message: 'Script error.' }))).toBe(true);
+ expect(isNonActionableNoise(ev({ name: 'AbortError', message: 'aborted' }))).toBe(true);
+ });
+
+ it('never touches resource/csp telemetry events', () => {
+ expect(isNonActionableNoise(ev({ type: 'resource', message: 'Internal JSON-RPC error.' }))).toBe(false);
+ expect(isNonActionableNoise(ev({ type: 'csp', message: 'Internal JSON-RPC error.' }))).toBe(false);
+ });
+});
diff --git a/workers/agora-citizens/config.js b/workers/agora-citizens/config.js
index 173ce2be3..34bd8ae76 100644
--- a/workers/agora-citizens/config.js
+++ b/workers/agora-citizens/config.js
@@ -14,6 +14,8 @@
// real token). $THREE is the only coin Agora promotes; on mainnet the reward
// label is '$THREE'. See docs/agora.md and CLAUDE.md.
+import { resolveDatabaseUrl } from '../../api/_lib/env.js';
+
function req(name) {
const v = process.env[name];
if (!v || !String(v).trim()) throw new Error(`[agora-citizens] missing required env var: ${name}`);
@@ -40,8 +42,13 @@ export function loadConfig() {
// DATABASE_URL is the projection sink. A dry run reads the board + plans but
// never writes, so it can run without a DB — handy for inspecting the loop
- // with zero side effects.
- const databaseUrl = dryRun ? opt('DATABASE_URL', '') : req('DATABASE_URL');
+ // with zero side effects. Resolve from DATABASE_URL or any standard
+ // Vercel-Postgres/Neon alias (POSTGRES_URL, NEON_DATABASE_URL, …) so the worker
+ // connects wherever the integration injected the string — matching db.js.
+ const databaseUrl = resolveDatabaseUrl() || '';
+ if (!dryRun && !databaseUrl) {
+ throw new Error('[agora-citizens] missing required env var: DATABASE_URL (or a POSTGRES_URL/NEON_DATABASE_URL alias)');
+ }
const cluster = (opt('AGORA_CLUSTER', 'devnet')).toLowerCase();
if (cluster !== 'devnet' && cluster !== 'mainnet') {