{"record":{"id":"9fccc2ca4d57480e","repo":"Stirling-Tools/Stirling-PDF","slug":"servermessage-error-message-failed-to-delet","errorCode":null,"errorMessage":"serverMessage || error?.message || Failed to delete account","messagePattern":"serverMessage \\|\\| error\\?\\.message \\|\\| Failed to delete account","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"frontend/editor/src/saas/services/accountDeletion.ts","lineNumber":30,"sourceCode":"}\n\nexport async function deleteCurrentAccount(\n  options?: DeleteAccountOptions,\n): Promise<void> {\n  const { data, error } = await supabase.functions.invoke<DeleteUserResponse>(\n    \"delete-user\",\n    {\n      body: {\n        notify_user: options?.notifyUser ?? true,\n      },\n    },\n  );\n\n  if (error || !data?.success) {\n    const serverMessage = data?.error;\n    const errorMessage =\n      serverMessage || error?.message || \"Failed to delete account\";\n    throw new Error(errorMessage);\n  }\n}\n","sourceCodeStart":12,"sourceCodeEnd":33,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/saas/services/accountDeletion.ts#L12-L33","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the server-provided data.error message (highest priority in the fallback chain) for the specific failure reason","Check the delete-user edge function logs in the Supabase dashboard","Verify the edge function has STRIPE_SECRET_KEY and SUPABASE_SERVICE_ROLE_KEY configured","Ensure the user's Supabase session is still valid when invoking (re-authenticate if needed)","If Stripe redaction is the cause, check the Stripe dashboard for the customer record"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Confirm session is valid before attempting account deletion\nconst { data: { session } } = await supabase.auth.getSession();\nif (!session) {\n  showReauthPrompt();\n  return;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await deleteCurrentAccount({ notifyUser: true });\n  await supabase.auth.signOut();\n  redirectToHome();\n} catch (e) {\n  const msg = e instanceof Error ? e.message : 'Account deletion failed';\n  setDeleteError(msg);\n  // Keep the user logged in — deletion failed, don't sign out\n}","preventionTips":["Verify STRIPE_SECRET_KEY and SUPABASE_SERVICE_ROLE_KEY are configured in the delete-user edge function","Confirm the user's session is still valid before invoking the edge function","Monitor the edge function for Stripe redaction failures and surface actionable errors to the user","Show the server-provided data.error to the user when available for actionable guidance"],"tags":["account-deletion","edge-function","supabase","billing","stripe","saas"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}