Skip to content

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

  1. Try the conversion again. Your credits were not deducted β€” the operation failed safely.
  2. If the error happens consistently, there may be a temporary issue with the credit system. Wait a few minutes and try again.
  3. You can verify your credit balance on the Credits page to confirm no credits were lost.

For Administrators

  1. Check Supabase for the deduct_credits function health. Verify it exists and has the expected signature:
    SELECT proname, proargtypes FROM pg_proc WHERE proname = 'deduct_credits';
  2. Look for structured logs containing β€œCredit deduction error (attempt N/2):” in Grafana. The log entry includes the specific database error.
  3. If the function is missing, re-run the migration that creates it. Check list_migrations to identify which migration version defines deduct_credits.
  4. The isTransientDbError() function in error-catalog.ts determines which errors trigger the automatic retry. Review this function if the retry behavior needs adjustment.
  5. Check for deadlocks if users are triggering multiple simultaneous conversions. The deduct_credits function should use row-level locking to prevent this.