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(agents): retry wedged wallet extensions and name the failing step in Solana mint errors

nirholasca598639b495
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 46559d3bf..0773ffd3a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
## 2026-07-26
+- **Agent minting recovers from wallet extension crashes** — Minting an agent on Solana could fail with an unexplained "An internal error has occurred" when the wallet extension's background process was wedged, before any transaction was built and with no SOL spent. The deploy flow now retries the wallet call once automatically, and if it still fails the error names the exact step (connecting, signing, or broadcasting) and tells you how to recover: unlock or restart the wallet extension and try again. (`/create-agent`) `[fix]`
- **Sniper fleet learns faster: honest honeypot verdicts and no more invisible losers** — Two fixes to the autonomous trading fleet from auditing its own record. The trade firewall now checks which leg of the simulated buy-and-sell round-trip failed: only a failed sell (the real cannot-exit shape) blocks a coin, while a buy leg that could not fund or price the probe is a warning instead of a false honeypot verdict. And the self-tuning optimizer no longer lets a strategy that has never won keep betting at full size below the minimum sample: zero wins over six or more real trades now triggers an automatic size reduction. (`/blog/autonomous-trading-experiment`) `[improvement, fix]`
## 2026-07-25
diff --git a/data/changelog.json b/data/changelog.json
index eb911d448..850d635db 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,15 @@
{
"$comment": "Curated changelog entries for three.ws, 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-26",
+ "title": "Agent minting recovers from wallet extension crashes",
+ "summary": "Minting an agent on Solana could fail with an unexplained \"An internal error has occurred\" when the wallet extension's background process was wedged, before any transaction was built and with no SOL spent. The deploy flow now retries the wallet call once automatically, and if it still fails the error names the exact step (connecting, signing, or broadcasting) and tells you how to recover: unlock or restart the wallet extension and try again.",
+ "tags": [
+ "fix"
+ ],
+ "link": "/create-agent"
+ },
{
"date": "2026-07-26",
"title": "Sniper fleet learns faster: honest honeypot verdicts and no more invisible losers",
diff --git a/public/changelog.json b/public/changelog.json
index bac45b1eb..5b387d7e6 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,11 +1,21 @@
{
- "generated_at": "2026-07-26T20:51:49.889Z",
+ "generated_at": "2026-07-26T20:58:48.329Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
"url": "https://three.ws"
},
"entries": [
+ {
+ "date": "2026-07-26",
+ "type": "update",
+ "title": "Agent minting recovers from wallet extension crashes",
+ "summary": "Minting an agent on Solana could fail with an unexplained \"An internal error has occurred\" when the wallet extension's background process was wedged, before any transaction was built and with no SOL spent. The deploy flow now retries the wallet call once automatically, and if it still fails the error names the exact step (connecting, signing, or broadcasting) and tells you how to recover: unlock or restart the wallet extension and try again.",
+ "link": "/create-agent",
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-07-26",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 8721d3e6d..5551bad9c 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -6,6 +6,14 @@
<atom:link href="https://three.ws/changelog.xml" rel="self" type="application/rss+xml"/>
<description>What's new on three.ws — features, improvements, and releases, newest first.</description>
<language>en</language>
+ <item>
+ <title>Agent minting recovers from wallet extension crashes</title>
+ <link>https://three.ws/create-agent</link>
+ <guid isPermaLink="false">2026-07-26:Agent minting recovers from wallet extension crashes</guid>
+ <pubDate>Sun, 26 Jul 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>Minting an agent on Solana could fail with an unexplained &quot;An internal error has occurred&quot; when the wallet extension's background process was wedged, before any transaction was built and with no SOL spent. The deploy flow now retries the wallet call once automatically, and if it still fails the error names the exact step (connecting, signing, or broadcasting) and tells you how to recover: unlock or restart the wallet extension and try again.</description>
+ </item>
<item>
<title>Sniper fleet learns faster: honest honeypot verdicts and no more invisible losers</title>
<link>https://three.ws/blog/autonomous-trading-experiment</link>
diff --git a/public/features.json b/public/features.json
index 5d53df522..0a72962e7 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-07-26T20:51:49.881Z",
+ "generated_at": "2026-07-26T20:58:48.322Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/src/erc8004/register-ui.js b/src/erc8004/register-ui.js
index 877d39d1c..715b98b1d 100644
--- a/src/erc8004/register-ui.js
+++ b/src/erc8004/register-ui.js
@@ -126,6 +126,14 @@ function _classifyDeployError(raw, err = null) {
/user rejected|user denied|cancelled|reject/i.test(m)) {
return 'You cancelled the signature request — no transaction was sent. Click Deploy to try again.';
}
+ // Wallet extension internal crash (Phantom and compatibles throw
+ // code -32603 "An internal error has occurred" when their background
+ // worker is wedged; the flow already retried once before landing here).
+ if (code === -32603 || /internal error has occurred/i.test(m)) {
+ return 'Your Solana wallet extension hit an internal error before any transaction was sent (no SOL was spent). '
+ + 'Unlock the wallet, or restart it from your browser’s extension manager, then click Deploy again. '
+ + 'If it keeps happening, disable other wallet extensions that may be overriding it and reload this page.';
+ }
// Insufficient gas / funds
if (/insufficient funds|not enough|gas/i.test(m)) {
return 'Insufficient funds — make sure your wallet has enough ETH (or SOL) to cover gas. Top up and retry.';
diff --git a/src/erc8004/solana-deploy.js b/src/erc8004/solana-deploy.js
index 2601dd742..ace2e4e54 100644
--- a/src/erc8004/solana-deploy.js
+++ b/src/erc8004/solana-deploy.js
@@ -86,6 +86,52 @@ async function waitForSolanaConfirmation(conn, signature, timeoutMs) {
throw new Error('Timed out waiting for Solana transaction confirmation.');
}
+/**
+ * Wallet extensions (Phantom and Phantom-compatible injectors) throw
+ * `{ code: -32603, message: 'An internal error has occurred' }` when their
+ * background service worker is wedged or asleep. A second call after a short
+ * pause routinely succeeds, so retry once before surfacing the failure.
+ */
+const WALLET_INTERNAL_ERROR = -32603;
+
+export function isWalletInternalError(e) {
+ return e?.code === WALLET_INTERNAL_ERROR
+ || /internal error has occurred/i.test(e?.message || '');
+}
+
+export async function withWalletRetry(step, fn) {
+ try {
+ return await fn();
+ } catch (first) {
+ if (!isWalletInternalError(first)) throw tagStep(first, step);
+ await new Promise((r) => setTimeout(r, 800));
+ try {
+ return await fn();
+ } catch (second) {
+ throw tagStep(second, step);
+ }
+ }
+}
+
+const STEP_LABELS = {
+ connect: 'Wallet connection failed',
+ prepare: 'Could not build the mint transaction',
+ sign: 'Wallet signature failed',
+ send: 'Could not broadcast the transaction',
+};
+
+/** Prefix the failing step onto the error without losing code/status. */
+export function tagStep(e, step) {
+ if (e?.step) return e;
+ const label = STEP_LABELS[step] || step;
+ const err = new Error(`${label}: ${e?.message || String(e)}`);
+ err.step = step;
+ if (e?.code !== undefined) err.code = e.code;
+ if (e?.status !== undefined) err.status = e.status;
+ if (e?.txSignature !== undefined) err.txSignature = e.txSignature;
+ return err;
+}
+
/**
* Run the Solana deploy flow end-to-end.
*
@@ -110,7 +156,7 @@ export async function runSolanaDeploy({ agent, network, vanity }) {
throw err;
}
- const conn = await wallet.connect();
+ const conn = await withWalletRetry('connect', () => wallet.connect());
const walletAddress = (conn?.publicKey || wallet.publicKey)?.toString();
if (!walletAddress) throw new Error('Could not read Solana wallet address.');
@@ -173,14 +219,19 @@ export async function runSolanaDeploy({ agent, network, vanity }) {
// `signAndSendTransaction` routes through the wallet's own RPC, which
// returns 403 "Access forbidden" intermittently on mainnet.
const endpoint = RPC[network] || RPC.mainnet;
- const signed = await wallet.signTransaction(tx);
+ const signed = await withWalletRetry('sign', () => wallet.signTransaction(tx));
const conn2 = new Connection(endpoint, 'confirmed');
const raw = signed.serialize();
- const signature = await conn2.sendRawTransaction(raw, {
- skipPreflight: false,
- preflightCommitment: 'confirmed',
- maxRetries: 5,
- });
+ let signature;
+ try {
+ signature = await conn2.sendRawTransaction(raw, {
+ skipPreflight: false,
+ preflightCommitment: 'confirmed',
+ maxRetries: 5,
+ });
+ } catch (e) {
+ throw tagStep(e, 'send');
+ }
// Wait for confirmation before calling the server.
const conn3 = new Connection(endpoint, 'confirmed');
diff --git a/tests/solana-deploy-wallet-errors.test.js b/tests/solana-deploy-wallet-errors.test.js
new file mode 100644
index 000000000..efdfa131a
--- /dev/null
+++ b/tests/solana-deploy-wallet-errors.test.js
@@ -0,0 +1,124 @@
+// Wallet-leg error handling in src/erc8004/solana-deploy.js.
+//
+// Field failure this covers (2026-07-26): the Create Agent wizard died with
+// "Deploy failed: An internal error has occurred" before the prep endpoint was
+// ever called. That string is a wallet extension's -32603 internal crash
+// (Phantom and Phantom-compatible injectors emit it when their background
+// worker is wedged). The contract: the flow retries the wallet call once, and
+// any surviving error names the failing step while preserving code/status so
+// the UI classifiers still recognize rejection (4001), forbidden, and
+// payment_required shapes.
+
+import { describe, it, expect, vi, afterEach } from 'vitest';
+import {
+ runSolanaDeploy,
+ withWalletRetry,
+ isWalletInternalError,
+ tagStep,
+} from '../src/erc8004/solana-deploy.js';
+
+function internalError() {
+ const e = new Error('An internal error has occurred');
+ e.code = -32603;
+ return e;
+}
+
+afterEach(() => {
+ delete globalThis.window;
+ vi.unstubAllGlobals();
+ vi.restoreAllMocks();
+});
+
+describe('isWalletInternalError', () => {
+ it('matches the -32603 code and the message with or without a code', () => {
+ expect(isWalletInternalError(internalError())).toBe(true);
+ expect(isWalletInternalError(new Error('An internal error has occurred'))).toBe(true);
+ expect(isWalletInternalError({ code: -32603 })).toBe(true);
+ });
+
+ it('does not match user rejection or generic failures', () => {
+ expect(isWalletInternalError({ code: 4001, message: 'User rejected the request' })).toBe(false);
+ expect(isWalletInternalError(new Error('failed to fetch'))).toBe(false);
+ expect(isWalletInternalError(null)).toBe(false);
+ });
+});
+
+describe('withWalletRetry', () => {
+ it('retries once on a wallet internal error and returns the second result', async () => {
+ const fn = vi.fn()
+ .mockRejectedValueOnce(internalError())
+ .mockResolvedValueOnce('ok');
+ await expect(withWalletRetry('connect', fn)).resolves.toBe('ok');
+ expect(fn).toHaveBeenCalledTimes(2);
+ });
+
+ it('tags the step when both attempts crash, preserving the code', async () => {
+ const fn = vi.fn().mockRejectedValue(internalError());
+ const err = await withWalletRetry('sign', fn).catch((e) => e);
+ expect(fn).toHaveBeenCalledTimes(2);
+ expect(err.step).toBe('sign');
+ expect(err.code).toBe(-32603);
+ expect(err.message).toBe('Wallet signature failed: An internal error has occurred');
+ });
+
+ it('does not retry non-internal errors (a user rejection stays a single prompt)', async () => {
+ const reject = Object.assign(new Error('User rejected the request'), { code: 4001 });
+ const fn = vi.fn().mockRejectedValue(reject);
+ const err = await withWalletRetry('connect', fn).catch((e) => e);
+ expect(fn).toHaveBeenCalledTimes(1);
+ expect(err.code).toBe(4001);
+ expect(err.step).toBe('connect');
+ expect(err.message).toMatch(/User rejected the request/);
+ });
+});
+
+describe('tagStep', () => {
+ it('is idempotent: an already-tagged error passes through untouched', () => {
+ const first = tagStep(internalError(), 'connect');
+ expect(tagStep(first, 'sign')).toBe(first);
+ });
+
+ it('preserves status and txSignature for the confirm-leg contract', () => {
+ const e = Object.assign(new Error('boom'), { status: 502, txSignature: 'sig123' });
+ const tagged = tagStep(e, 'send');
+ expect(tagged.status).toBe(502);
+ expect(tagged.txSignature).toBe('sig123');
+ expect(tagged.message).toBe('Could not broadcast the transaction: boom');
+ });
+});
+
+describe('runSolanaDeploy wallet leg', () => {
+ it('surfaces a step-tagged error when connect crashes twice', async () => {
+ const wallet = { isPhantom: true, connect: vi.fn().mockRejectedValue(internalError()) };
+ globalThis.window = { phantom: { solana: wallet }, location: { origin: 'https://three.ws' } };
+ const err = await runSolanaDeploy({ agent: { id: 'a', name: 'A' }, network: 'mainnet' }).catch((e) => e);
+ expect(wallet.connect).toHaveBeenCalledTimes(2);
+ expect(err.step).toBe('connect');
+ expect(err.code).toBe(-32603);
+ expect(err.message).toBe('Wallet connection failed: An internal error has occurred');
+ });
+
+ it('recovers when the second connect succeeds and proceeds to the prep call', async () => {
+ const wallet = {
+ isPhantom: true,
+ connect: vi.fn()
+ .mockRejectedValueOnce(internalError())
+ .mockResolvedValueOnce({ publicKey: { toString: () => '7ownerPubkey11111111111111111111111111111111' } }),
+ };
+ globalThis.window = { phantom: { solana: wallet }, location: { origin: 'https://three.ws' } };
+ const fetchMock = vi.fn().mockResolvedValue({
+ ok: false,
+ status: 403,
+ json: async () => ({ error: 'forbidden', error_description: 'wallet not linked to your account' }),
+ });
+ vi.stubGlobal('fetch', fetchMock);
+
+ const err = await runSolanaDeploy({ agent: { id: 'a', name: 'A' }, network: 'mainnet' }).catch((e) => e);
+ expect(wallet.connect).toHaveBeenCalledTimes(2);
+ expect(fetchMock).toHaveBeenCalledWith('/api/agents/solana-register-prep', expect.objectContaining({ method: 'POST' }));
+ // The prep leg's server envelope survives untouched for the UI classifier.
+ expect(err.code).toBe('forbidden');
+ expect(err.status).toBe(403);
+ expect(err.message).toBe('wallet not linked to your account');
+ });
+});