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(_handlers.js): improve error handling in handleRegisterPrep with fallback for RPC failures

nirholas87146155b53d
diff --git a/api/agents/solana/_handlers.js b/api/agents/solana/_handlers.js
index 5c22d0d31..defcd4209 100644
--- a/api/agents/solana/_handlers.js
+++ b/api/agents/solana/_handlers.js
@@ -341,11 +341,18 @@ export const handleRegisterPrep = wrap(async (req, res) => {
let assetSigner, txBytes;
try {
({ assetSigner, txBytes } = await buildTx(configuredRpc));
- } catch (err) {
- const isAuthErr = err?.message?.includes('401') || err?.message?.includes('Unauthorized') || err?.message?.includes('invalid api key');
- if (!isAuthErr || configuredRpc === publicRpc) throw err;
- console.warn('[solana/register-prep] configured RPC auth failed, retrying with public RPC');
- ({ assetSigner, txBytes } = await buildTx(publicRpc));
+ } catch (rpcErr) {
+ if (configuredRpc === publicRpc) {
+ console.error('[solana/register-prep] public RPC failed:', rpcErr.message);
+ return error(res, 503, 'rpc_unavailable', 'Solana RPC temporarily unavailable — try again in a moment.');
+ }
+ console.warn('[solana/register-prep] configured RPC failed, retrying with public RPC:', rpcErr.message);
+ try {
+ ({ assetSigner, txBytes } = await buildTx(publicRpc));
+ } catch (fallbackErr) {
+ console.error('[solana/register-prep] public RPC fallback also failed:', fallbackErr.message);
+ return error(res, 503, 'rpc_unavailable', 'Solana RPC temporarily unavailable — try again in a moment.');
+ }
}
const txBase64 = Buffer.from(txBytes).toString('base64');
diff --git a/vercel.json b/vercel.json
index 5b22b0b0f..34805d9fb 100644
--- a/vercel.json
+++ b/vercel.json
@@ -412,6 +412,14 @@
"src": "/api/auth/x/callback",
"dest": "/api/auth/x/[action]?action=callback"
},
+ {
+ "src": "/api/auth/wallets",
+ "dest": "/api/auth/wallets/[action]"
+ },
+ {
+ "src": "/api/auth/wallets/([^/]+)",
+ "dest": "/api/auth/wallets/[action]?action=$1"
+ },
{
"src": "/api/auth/wallet/link",
"dest": "/api/auth/wallet/[action]?action=link"