ERR_CREDITS_DEDUCTION_FAILED β Credits Deduction Failed
HTTP Status: 500 Retryable: Yes Automatic retry: The system retries once on transient database errors (timeout, connection reset). This error surfaces after both attempts fail.
What the User Sees
Failed to process credit deduction. (ERR_CREDITS_DEDUCTION_FAILED)
What Causes This Error
The deduct_credits Supabase RPC function call failed. This function atomically checks the userβs credit balance and deducts the required number of credits for the conversion. The system retries once if the first attempt fails with a transient database error (as determined by the isTransientDbError() function in error-catalog.ts).
This error means both attempts failed. Importantly, the conversion will NOT proceed when this happens β no credits were charged and no conversion work was performed. The operation is safe to retry without risk of double-charging.
Transient causes include: database connection timeout, Supabase momentary unavailability, or a deadlock on the userβs credit row (if multiple simultaneous conversions are attempted). Persistent causes include: the deduct_credits RPC function being missing or having a schema mismatch after a migration issue.
Resolution Steps
For Users
- Try the conversion again. Your credits were not deducted β the operation failed safely.
- If the error happens consistently, there may be a temporary issue with the credit system. Wait a few minutes and try again.
- You can verify your credit balance on the Credits page to confirm no credits were lost.
For Administrators
- Check Supabase for the
deduct_creditsfunction health. Verify it exists and has the expected signature:SELECT proname, proargtypes FROM pg_proc WHERE proname = 'deduct_credits'; - Look for structured logs containing βCredit deduction error (attempt N/2):β in Grafana. The log entry includes the specific database error.
- If the function is missing, re-run the migration that creates it. Check
list_migrationsto identify which migration version definesdeduct_credits. - The
isTransientDbError()function inerror-catalog.tsdetermines which errors trigger the automatic retry. Review this function if the retry behavior needs adjustment. - Check for deadlocks if users are triggering multiple simultaneous conversions. The
deduct_creditsfunction should use row-level locking to prevent this.
Related Errors
- ERR_CREDITS_INSUFFICIENT β User does not have enough credits (normal business logic)
- ERR_DB_CONNECTION_FAILED β Database is unreachable