mastra-ai/mastra · error
Failed to create account
Error message
Failed to create account
What it means
Thrown by signUp in @mastra/auth/neon when the Neon signup HTTP request returns a non-OK response and the error body carries no readable message, or when the parsed response JSON is missing a `user` field. It is a guard against a signup that did not actually create an account, so the caller never gets an invalid session object.
Source
Thrown at auth/neon/src/index.ts:334
email: string,
password: string,
name: string | undefined,
request: Request,
): Promise<CredentialsResult<EEUser>> {
const displayName = name ?? email.split('@')[0] ?? 'User';
const response = await fetch(`${this.baseUrl}/auth/sign-up/email`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(request?.headers ? Object.fromEntries(request.headers.entries()) : {}),
},
body: JSON.stringify({ email, password, name: displayName }),
});
if (!response.ok) {
const errorData = (await response.json().catch(() => ({}))) as { message?: string };
throw new Error(errorData.message || 'Failed to create account');
}
const result = (await response.json()) as { user?: NeonSessionResponse['user']; token?: string | null };
if (!result?.user) {
throw new Error('Failed to create account');
}
const cookies = parseCookies(response);
return {
user: mapNeonUserToEEUser(result.user),
token: result.token ?? undefined,
cookies,
};
}
// ── ISessionProvider ──View on GitHub (pinned to 75dd419e61)
Solutions
- Check the server response status/body (log the raw response) to see the real Neon API error such as email-already-registered or weak-password.
- Verify the Neon auth endpoint/base URL configuration points at the correct environment.
- Retry with a different email or a password that satisfies Neon's policy.
- If the API is intermittently failing, retry after checking Neon service status.
Example fix
// before
await auth.signUp('user@example.com', '123', 'User');
// after
try {
await auth.signUp('user@example.com', 'a-strong-password-123!', 'User');
} catch (e) {
console.error('Signup failed:', e.message); // inspect upstream Neon error
} Defensive patterns
Strategy: try-catch
Validate before calling
const emailOk = /[^@]+@[^@]+\.[^@]+/.test(email);
const passwordOk = typeof password === 'string' && password.length >= 8;
if (!emailOk || !passwordOk) throw new Error('Invalid signup input'); Type guard
function isSignupResult(r: unknown): r is { user: { id: string }; token?: string | null } {
return !!r && typeof r === 'object' && 'user' in r && !!(r as any).user;
} Try / catch
try {
await auth.signUp(email, password, name);
} catch (e) {
if (e instanceof Error && e.message === 'Failed to create account') {
// surface a user-facing message (e.g. email already in use) and let them retry
} else throw e;
} Prevention
- Check whether the email already exists before offering signup.
- Enforce password policy on the client before calling signUp.
- Log the upstream response when debugging to capture Neon's real error.
When it happens
Trigger: Calling signUp(email, password, displayName) when the Neon auth API rejects the request (e.g. duplicate email, weak password, 4xx/5xx with an empty or unparseable error body), or when the API returns 200 with a body lacking `user`.
Common situations: User already exists with that email; password policy violation; Neon API downtime or proxy returning HTML error pages that fail JSON parsing; misconfigured NEON auth base URL causing an unexpected response shape.
Related errors
- Token exchange failed: ${error}
- Failed to fetch user info from Clerk
- Google service account token request failed (${response.stat
- invalid API key or insufficient permissions
- Auth check failed (${res.status})
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/d92f9cb42475f2df.
Report an issue: GitHub.