Troubleshooting guide

Payments, emails and access rules failing silently in production

The app works in testing. In production, a payment never grants access, a sign-in email never arrives, or one user can read another user's rows, and the logs say nothing. In our data this pattern ranks 6 of 7 by size, with 68 verified cases. The common cause is a path that was only tested against a fake, combined with an error that was swallowed instead of shown.

68 verified cases14 min read Updated 16 Nov 2026Last reviewed 17 Nov 2026Fix it with GemmeinHow we collect cases

What you'll see

  • A customer has paid in Stripe but the order stays pending, or the account stays on the free plan.
  • Stripe's webhook delivery log shows repeated failures, or the endpoint has been deleted or disabled, and nobody noticed.
  • Sign-in, verification or password-reset emails never arrive, or land in spam, and only some addresses are affected.
  • Emails work on your laptop but time out or hang once the app is on the host.
  • A table can be read or written with the public (anonymous) key, or one logged-in user can see another user's data.
  • A readiness or health flag says everything is active while checkout returns an error.

Why it happens

Cause 1

Access rules were written by hand and tested with one user

With one account, every query returns your own rows, so a missing or too-broad rule looks fine. On Supabase, a table in an exposed schema without RLS is readable and writable by any role with a grant on it, and a policy written to anon using ( true ) opens every reachable row to signed-out visitors. OWASP lists missing deny-by-default and missing record-ownership checks as the core of broken access control.

Cause 2

The webhook endpoint fails, or was never reachable in production

Stripe treats a redirect as a failure, and a 401, 403, 404 or 405 as an endpoint that is restricted, missing or not accepting post requests. Signature verification fails if a framework parses the body before your code sees it, or if the signing secret is the wrong one. The CLI secret differs from the dashboard endpoint's secret, and test and live secrets differ. If the endpoint is slow, Stripe sees a timeout. Live-mode retries stop after about three days, so a long outage loses events unless you replay them.

Cause 3

Email runs on a sandbox, a default sender or a blocked port

Supabase's built-in SMTP service refuses addresses that are not part of the project's team, is currently limited to 2 messages per hour and is documented as not meant for production. After you add custom SMTP, Supabase applies an initial limit of 30 messages per hour until you change it. Render blocks outbound port 25 for all services, and ports 25, 465 and 587 for free web services, so SMTP connections hang. A disabled provider key, a rejected sender address or a suppressed recipient produces the same symptom: no email and no visible error.

Cause 4

Failures are swallowed and nobody is alerted

A catch that logs and returns 200, an event with no subscriber, or a readiness flag cached from an earlier check each turn a broken path into a quiet one. A hard bounce to a dead address that is never removed also damages your sending reputation over time. OWASP's guidance is to log access control failures and alert admins when appropriate. The same applies to payment and email paths.

How to fix it

  1. List every table the anonymous role can reach and turn RLS on

    Find tables in the exposed schema without RLS, enable it, then revoke the default grants and grant back only what each role needs. With RLS on and no policies, the API returns no data until you create them. That is the safe starting point.

    select schemaname, tablename
    from pg_tables
    where schemaname = 'public' and not rowsecurity;
    
    alter table public.orders enable row level security;
    revoke all on table public.orders from anon, authenticated;
    grant select, insert on table public.orders to authenticated;
    
    create policy "own rows" on public.orders
      for select to authenticated
      using ( auth.uid() = user_id );
  2. Test every table as two different users

    Switch identity inside a transaction and confirm user A sees none of user B's rows. A using filter that matches nothing raises no error, so assert an empty result instead of expecting an exception. Keep these tests in CI (Supabase documents pgTAP files run with supabase test db).

    begin;
    set local role authenticated;
    set local request.jwt.claim.sub = '<user-a-uuid>';
    select count(*) from public.orders
      where user_id = '<user-b-uuid>';  -- expect 0
    rollback;
  3. Make the webhook handler verify, acknowledge, then work

    Read the raw body, verify the Stripe-Signature header with the endpoint's own whsec_ secret, return a 2xx quickly and do the slow work afterwards. Record processed event ids, because Stripe can deliver the same event twice and does not guarantee order.

    export async function POST(req: Request) {
      const body = await req.text(); // raw, not req.json()
      const sig = req.headers.get("stripe-signature")!;
      const event = stripe.webhooks.constructEvent(
        body, sig, process.env.STRIPE_WEBHOOK_SECRET!
      );
      // skip if event.id was already stored, else enqueue the work
      return new Response(null, { status: 200 });
    }
  4. Read the delivery log, fix the status code, replay what was missed

    In Workbench, open the endpoint's Event deliveries tab to see Delivered, Pending or Failed and the HTTP status of each attempt. After fixing the cause, list undelivered events (Stripe returns events from the last 30 days) and resend them. The CLI can resend events up to 30 days old, the dashboard up to 15.

    curl -G https://api.stripe.com/v1/events \
      -u "$STRIPE_SECRET_KEY:" \
      -d "types[]=checkout.session.completed" \
      -d delivery_success=false
    
    stripe events resend evt_123 --webhook-endpoint=we_123
  5. Send one real email through the production path

    Use your own provider with a verified sending domain and SPF or DKIM records, not the platform default. From the production host, check that the SMTP port you use is not blocked (see the host's docs). If the host restricts SMTP, use your provider's HTTP API. Raise any low default send cap before launch.

  6. Handle bounces, suppression and unsubscribe headers

    Open a bounced message in your provider to see its type. Resend, for example, separates permanent, transient and undetermined bounces, and lets you remove an address from its suppression list. Stop sending to permanent bounces. Google requires senders of 5,000 or more messages a day to authenticate with SPF, DKIM and DMARC. It also requires marketing and subscribed messages to support one-click unsubscribe with the List-Unsubscribe and List-Unsubscribe-Post headers. Keep promotional content out of receipts and codes.

    List-Unsubscribe-Post: List-Unsubscribe=One-Click
    List-Unsubscribe: <https://example.com/unsubscribe/abc123>
  7. Alert on silence, and stop swallowing errors

    When a handler cannot record a payment, return a non-2xx status so Stripe retries it. Alert on failed webhook deliveries, email send errors and bounce rates. Log refused access attempts and alert on repeats.

Check it's fixed

  • Run the two-user test on every table. User A reading user B's rows returns zero, and the anonymous role returns nothing on tables that are not meant to be public.
  • Make a small real payment in live mode. Confirm the delivery shows Delivered in Event deliveries and that access was granted exactly once.
  • Request a sign-in code to a fresh address on a different mail provider and confirm it reaches the inbox, not spam, within a minute.
  • Break each path on purpose in staging (wrong webhook secret, revoked mail key) and confirm that an alert reaches you.

Fix it with Gemmein

Gemmein registers the Stripe webhook itself and re-checks it on a schedule, verifies other providers' webhooks against a declared signature recipe, and retries a failed relay run before marking it dead and alerting the owner. Collections are declared with their rule before the app writes to them, and hosted pages report each Gemmein call that failed or was refused.

  1. Connect Stripe with a restricted key and let Gemmein own the webhook

    A restricted key pasted on each environment's Payments page registers one webhook endpoint in your Stripe with the eleven events it needs. Gemmein checks the webhook every 6 hours and the key every day; a webhook that is deleted, disabled, pointed elsewhere or missing events is named with "Repair webhook", shown on the Payments page, Home and Errors, and emailed to the owner once.

    // upgrade button
    await g.subscriptions.checkout("pro");
    
    // gate features
    const sub = await g.subscriptions.mine();
    if (sub?.plan === "pro") { /* pro features */ }
  2. Take other providers' payments through a receiver relay

    A receiver at POST /hooks/<appId>/<name> checks the sender's signature with a verify recipe. If the recipe describes the signature differently from how the sender signs, every event answers 401 bad_signature and nothing runs. A failed run retries after 1 min, 5 min, 30 min, 2 h, 8 h and 16 h, then is dead, and the owner is alerted and can replay it.

    { "scheme": "signature", "header": "Paddle-Signature", "timestampKey": "ts", "signatureKey": "h1", "separator": ";", "signedPayload": "{timestamp}:{body}" }
  3. Declare each collection with its rule before the app writes to it

    Write gemmein/collections/<name>.json with its rule and, for community, shared and direct collections, its fields; the fields you declare are exactly what Development enforces and exactly what goes live. Going live answers 400 undeclared_collections while any community, shared or direct collection is undeclared, and site_test journeys can walk the app as a named test member ("sign in as alice").

  4. Read what the live pages hit

    Every page Gemmein hosts reports each Gemmein call that failed or was refused, with its status and refusal code, grouped with how often and the page. The Live site's pages report from real visitors; reading them needs the live:read grant, which your human approves in the browser.

    npx gemmein login --live-read
    npx gemmein site errors --live

Specific fixes

Stuck on one exact error? These pages go deeper on one symptom each.

Questions

Why does my Stripe webhook work locally but fail in production?

The usual causes are a different signing secret (the stripe listen secret differs from the dashboard endpoint's secret, and test and live differ), a framework that parses the body before verification, or a route that does not accept post requests. Check the status code of each attempt in Event deliveries.


How long does Stripe keep retrying a failed webhook?

In live mode, Stripe retries for up to three days with exponential backoff. Events created in a sandbox are retried three times over a few hours. After that, list undelivered events and resend them.


Why do only some users receive my sign-in emails?

On Supabase's default SMTP service, only addresses that belong to the project's team receive mail, and the cap is currently 2 messages per hour. Other providers have sandbox modes, suppression lists or send caps that behave similarly. Check the provider's delivery log for the missing address.


Is RLS enough to secure a Supabase table?

RLS with correct policies is the control, but untested policies prove nothing. Supabase notes that policies alone do not remove default grants, so revoke them from anon and authenticated and grant back only what is needed. Then test allow and deny cases for each role.


Do transactional emails need an unsubscribe header?

Google's sender guidelines require one-click unsubscribe for marketing and subscribed messages from bulk senders, and say not to mix content types in one message. They do not say transactional messages need it, so keep codes and receipts free of promotion.


Sources

Last reviewed 17 Nov 2026. What changed: No changes: steps re-checked against 8 official page(s). Checked against: supabase.com, supabase.com, docs.stripe.com, docs.stripe.com, render.com, resend.com, support.google.com, top10.owasp.org. How we check this

← Back to the full report