Skip to main content

Subscribe to GoRails to get access to this episode and all other pro episodes, and new awesome content every month.

Subscribe Now
Only $19/month

Unlimited access. Cancel anytime.

7 Webhooks with Rails:

Sending Webhooks with Exponential Backoff

Episode 255 · July 26, 2018

Sending Webhooks in Rails is easy, but what happens when the request fails? You'll need to implement retries and exponential backoff so you don't DoS their service

Webhooks


Transcripts

No transcripts available. Earn a free month

Discussion


Fallback

Hi,

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,
          name: user.name,
        }
      })
    end
  end

Wouldn't that be sending the wrong user.name? 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 self.user.name would fix that.


Fallback

Sidekiq has an automatic job retry with exponential backoff:
https://github.com/mperham/sidekiq/wiki/Error-Handling#automatic-job-retry

Why didn't you use that?


Login or create an account to join the conversation.