PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 6, 2022

[FIXED] How to prevent retrying for some Exception/Error on sidekiq

 September 06, 2022     exception, mailchimp-api-v3.0, ruby, ruby-on-rails, sidekiq     No comments   

Issue

I have a sidekiq worker which will request 3rd party api(Mailchimp) and got some response. Sometimes it will response an error message which the api gem will raise an error.

However, those Errors are normal and no need to retry. So I would like Sidekiq prevent retry when those Errors raised.

I have tried a simply rescue, but it won't prevent the sidekiq capture the error raised.

def preform(id)
  UpdateMailchimpService.new.(id)
rescue
  Mailchimp::ListInvalidBounceMemberError
end

Any way to do this? Thanks

Update

Finally found that my problem was caused by the broken of our deploy tool(deployment failed but not realised). Actually, the Sidekiq will ignore any rescued error/exception and they are not be retried and reported to Bugsnag.

In Bugsnag's documentation, it clearly said:

Bugsnag should be installed and configured, and any unhandled exceptions will be automatically detected and should appear in your Bugsnag dashboard.

This post on github didn't have an clear explanation so that's why I am confused by this question.


Solution

Your assumption/example is incorrect. Do the normal Ruby thing: rescue the error and ignore it.

def perform(id)
  begin
    UpdateMailchimpService.new.(id)
  rescue NormalError
    # job will succeed normally and Sidekiq won't retry it.
  end
end


Answered By - Mike Perham
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing