All threads / Sending Webhooks with Exponential Backoff Discussion
Ask A Question


You’re not receiving notifications from this thread.

Sending Webhooks with Exponential Backoff Discussion


love the episode!

Just a tiny remark; when running this code;

  def send_create_webhook!
    User.has_webhook_enabled.find_each do |user|
      SendWebhookJob.perform_later(user.webhook_url, {
        type: "tweet.created",
        id: id,
        body: body,
        user: {
          id: user_id,

Wouldn't that be sending the wrong You pass in the user that wants to receive the webhook and in the body, you refer to that webhook user, instead of the user that created the tweet.

I think refering to would fix that.

Sidekiq has an automatic job retry with exponential backoff:

Why didn't you use that?

I make a change to use Sidekiq retry

class SendWebhookJob < ApplicationJob
WebhookNotFound =

retry_on WebhookNotFound
queue_as :default


def perform(webhook_url, data)
puts "#{} : Sending data to #{webhook_url}"

response =, json: data)
successful = response.code == 200 || raise(WebhookNotFound)


Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 68,326+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.