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

Showing Posts 1 to 5

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.

benonymus

benonymus OP

Thanks for the reply!

Yeah, we have error reporting.
I will make this change and see if it affects anything.
As for read_body, we seems to go past that point.

benonymus

benonymus OP

It seems like changing to this setup fixes the problem.

Thanks!

adao

adao

I ran into the same problem when using the same article you mentioned as reference . I believe I found the fix . In Connor’s code , I believe the offending lines are :

{:ok, body, _} = Plug.Conn.read_body(conn)
conn

The conn returned is ‘stale’ in a sense . So I changed this to

{:ok, body, conn} = Plug.Conn.read_body(conn)
conn

and the problem seems to have gone away . I haven’t done any further digging into exactly why this is the case (the exact difference between the conn passed into Plug.Conn.read_body and the one that comes out , and how this affects the pipeline downstream . If anyone has insight , am curious to know)

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews