Webhooks (localhost) in Clerk fails for the most part

I’m not quite sure I understand the subject (Webhooks) in particular. Currently I am running a localTunnel instance and’ve put the URL into clerks Webhook-endpoint. Sometimes when I run the example (Testing), my Webhook code is being executed and does what its supposed to (user.created). But if I like try to run the example again, it always fail. Does anyone know the reason for this? Receiving a Timeout-status code. If I also remove my user from the User-table in Clerk and re-login in to my application. The Webhook is never executed.
12 Replies
James Perkins
James Perkins14mo ago
Localtunnel / Ngrok are both incredibly fragile, I find at least once every few requests I have to restart Localtunnel and with ngrok it's once in a while. This has less to do with Clerk and more to do with the poor tools in the industry. Ngrok is less fragile because they charge people to tunnel out their URLs Part 2: We will always create a webhook for new users. Here is my logs from right now showing you deleting and recreating the same user:
No description
frenetic.ts
frenetic.ts14mo ago
Oh okay, got it! I assume that you always need to restart and swap the url in the dashboard then? Hm, yes so I managed to get the example to work one time (the data from the payload was inserted to my database). But like when I delete my user from Clerks dashboard, re-launch the localTunnel, re-launch the dev environment and signs in, it doesnt create a new user. However, I often see an event in the Logs, but it spins around at ”Attempting”. Any ideas what I might be doing wrong?
James Perkins
James Perkins14mo ago
if we are attempting that means one of two things, the request fails. if click into it it should show a failed request and a retry potential. you code isn’t handling a situation and not returning a response
frenetic.ts
frenetic.ts14mo ago
Hm okay! Ye it seems like the response code is a 400 and the response itself is an empty object. Not sure why. I just relaunched localTunnel and sent a user.created event as a test in Clerks dashboard. Succeded right away 😅 What differs the testing part from my end? Webhook secret? I put mine in the top-level .env file (create-t3-turbo).
James Perkins
James Perkins14mo ago
if it’s a 400 you need to look at anywhere where 400 are return throw a log in there and see what is happening
ejoo
ejoo14mo ago
ngrok works fine for me. I have tried using https://webhookthing.com/ by theo it works great on local without a tunnel. but can't figure out what header to set for it to work with clerk secret token verification. any advice for this @jamesperkins
webhookthing
an easier way to develop with webhooks locally
James Perkins
James Perkins14mo ago
You need like 3 headers to verify the the hook. ("svix-id"); ("svix-timestamp"); ("svix-signature"); It’s not easy to do with webhook thing currently but we have talked about having a 1st class integration when Theo myself and Mark have time
natef
natef9mo ago
Is there any news on this potential integration for smoothing out the webhook experience with Clerk? I was hoping that localhost development, specifically with syncing Clerk data with my own backend, would be a little more streamlined.
James Perkins
James Perkins9mo ago
What part is cauasing friction ?
natef
natef9mo ago
So I'm currently in a planning stage and considering using Ngrok to expose my local server for webhook integration with Clerk. My reservation about this approach is that Ngrok's free tier generates a new random URL each time it restarts. This would mean that I'll have to manually update the webhook URL in Clerk's dashboard every time, which isn't very efficient. Additionally, I've read your concerns above about the reliability of tunneling services, making me a bit hesitant. -- You mention that "Localtunnel / Ngrok are both incredibly fragile" (granted I don't have extensive experience with these myself) Would you be able to suggest a more streamlined or stable approach? I'm open to corrections or alternative solutions.
James Perkins
James Perkins9mo ago
Well the fragility comes from tunneling machines less the product. Creating and testing webhooks with Clerk should take less then an hour. In the current landscape of webhhooks using a tunneling system is basically your only option outside of developing in a reverse proxy or deploying and working from there. From a Clerk standpoint we are pretty streamlined. 1. Create webhook listening in your app. It's strongly typed. 2. Setup your local env to expose. 3. Add URL, test scenarios. 4. Done
stumpykilo
stumpykilo8mo ago
this is an awesome tool, thank you! how does one generate the required svix headers that clerk requires? i'm getting message like "No matching signature found" and "timestamp too new"