benonymus

benonymus

Hey,

I am experiencing something strange with Stripe webhooks.

We have a setup based on this article: https://connerfritz.com/blog/stripe-webhooks-in-phoenix-with-elixir-pattern-matching

We noticed some failing webhooks on the Stripe dashboard that say they got no response body (which should not happen, we send a response on every case from the relevant controller).

I started to look into it, and it looks like the request does not make it to the controller at all.

I added a plug to log when a step is passed in the endpoint.ex file.

  plug xxxWeb.StripeValidationPlug

  plug xxxWeb.LoggerPlug, msg: "passed stripe validation plug"

  plug Plug.Parsers,
    parsers: [:urlencoded, :multipart, :json],
    pass: ["*/*"],
    json_decoder: Phoenix.json_library(),
    # Max 1GB
    length: 1_000_000_000

  plug xxxWeb.LoggerPlug, msg: "passed Parsers plug"

Based on these logs it looks like we don’t make it past Plug.Parsers.

There are no errors, or any logs that would explain why this happens.

The only thing we see is that the request comes in and there is no response.

On other requests we see that the request came and response went:

Dec 16 09:57:11 AM  02:57:11.239 request_id=FzEmpgYZGousJoYADq7B [info] GET /healthz
Dec 16 09:57:11 AM  02:57:11.247 request_id=FzEmpgYZGousJoYADq7B [info] Sent 200 in 7ms

But for this we only see the incoming part:

Dec 16 09:57:07 AM  02:57:07.705 request_id=FzEmpTNucr4YJUoADq2B [info] POST /stripe_callback

I tried the same Stripe event, and sometimes it passes sometimes it doesn’t.

Any idea why this might be?
Or ideas to debug this?
Only happens on prod, seems rock solid locally/staging.

Thanks

Marked As Solved

stefanchrobot

stefanchrobot

Seems like the request is crashing, so it’s strange that there are no errors or logs. Do you have an error reporting service set up?

If you can’t find the root cause, I’d suggest changing the approach and doing it the “recommended” way by implementing a custom body reader: I’ve successfully done this before for validating webhooks that required the raw request body. Please keep in mind that the example code needs some tweaking since Plug.Conn.read_body can return 3 different things.

Here’s my not-so-perfect implementation.

Also Liked

benonymus

benonymus OP

It seems like changing to this setup fixes the problem.

Thanks!

Last Post!

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
csmr
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley: Mutonex gamedesign was finish...
New
perzanko
Do we have maintainer of absinthe-graphql/dataloader here? We have a PR that we’d like to merge to the library. Relatively small additive...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews