Stirling-Tools/Stirling-PDF · critical · Error

serverMessage || error?.message || Failed to delete account

Error message

serverMessage || error?.message || Failed to delete account

What it means

Thrown by deleteCurrentAccount() when the delete-user edge function either returns an error or returns a response with success !== true. The error message prioritizes the server-provided data.error, falls back to the Supabase FunctionsError message, then a generic string. This is the account self-deletion path (the user deleting their own account).

Source

Thrown at frontend/editor/src/saas/services/accountDeletion.ts:30

}

export async function deleteCurrentAccount(
  options?: DeleteAccountOptions,
): Promise<void> {
  const { data, error } = await supabase.functions.invoke<DeleteUserResponse>(
    "delete-user",
    {
      body: {
        notify_user: options?.notifyUser ?? true,
      },
    },
  );

  if (error || !data?.success) {
    const serverMessage = data?.error;
    const errorMessage =
      serverMessage || error?.message || "Failed to delete account";
    throw new Error(errorMessage);
  }
}

View on GitHub (pinned to 9ef20dcab8)

Solutions

  1. Read the server-provided data.error message (highest priority in the fallback chain) for the specific failure reason
  2. Check the delete-user edge function logs in the Supabase dashboard
  3. Verify the edge function has STRIPE_SECRET_KEY and SUPABASE_SERVICE_ROLE_KEY configured
  4. Ensure the user's Supabase session is still valid when invoking (re-authenticate if needed)
  5. If Stripe redaction is the cause, check the Stripe dashboard for the customer record
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm session is valid before attempting account deletion
const { data: { session } } = await supabase.auth.getSession();
if (!session) {
  showReauthPrompt();
  return;
}

Try / catch

try {
  await deleteCurrentAccount({ notifyUser: true });
  await supabase.auth.signOut();
  redirectToHome();
} catch (e) {
  const msg = e instanceof Error ? e.message : 'Account deletion failed';
  setDeleteError(msg);
  // Keep the user logged in — deletion failed, don't sign out
}

Prevention

When it happens

Trigger: The delete-user edge function fails because the Stripe customer redaction job errors, the Supabase admin API call fails, the user is not found, or the function encounters an internal error. Also fires on transport-level errors invoking the function.

Common situations: User has an active Stripe subscription that fails to cancel; edge function encounters a Stripe API error during redaction; Supabase service key or admin permissions misconfigured in the edge function; user's auth session expired between UI action and the function call.

Related errors


AI-assisted analysis of Stirling-Tools/Stirling-PDF@9ef20dcab8 (2026-08-13). Data as JSON: /api/errors/9fccc2ca4d57480e. Report an issue: GitHub.