Skip to content

retry_criteria_check is not triggered if @retry_exceptions and @fatal_exceptions are unset #145

Description

@oehlschl

retry_criteria_check methods are not triggered if both @retry_exceptions and @fatal_exceptions are nil per lines:

https://github.com/lantins/resque-retry/blob/v1.5.0/lib/resque/plugins/retry.rb#L275
https://github.com/lantins/resque-retry/blob/v1.5.0/lib/resque/plugins/retry.rb#L199

This case seems like a common one (defining a criteria check method without whitelisting or blacklisting any exception classes), and the behavior is not at all intuitive: the only constraint I define is not called because I didn't define others. For now, setting @retry_exceptions = [] is a sufficient workaround to fail the nil check without introducing unintended consequences, but retry_exceptions should not be required like this.

Never calls retry_criteria_check, always re-retries (up to limit):

  extend Resque::Plugins::Retry

  @retry_limit = 3
  @retry_delay = 60
  retry_criteria_check do |exception, *args|
    exception.is_a?(Mandrill::Error) && exception.message.include?('504 Gateway Time-out')
  end

Works as expected, calling retry_criteria_check logic:

  extend Resque::Plugins::Retry

  @retry_limit = 3
  @retry_delay = 60
  @retry_exceptions = []
  retry_criteria_check do |exception, *args|
    exception.is_a?(Mandrill::Error) && exception.message.include?('504 Gateway Time-out')
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions