• E
    Don't run AJ after_enqueue / after_perform when chain is halted: · bbfab0b3
    Edouard CHIN 提交于
    - ### Problem
    
      ```ruby
        MyJob < ApplicationJob
          before_enqueue { throw(:abort) }
          after_enqueue { # enters here }
        end
      ```
      I find AJ behaviour on after_enqueue and after_perform callbacks
      weird as they get run even when the callback chain is halted.
      It's counter intuitive to run the after_enqueue callbacks even
      though the job wasn't event enqueued.
    
      ### Solution
    
      In Rails 6.2, I propose to make the new behaviour the default
      and stop running after callbacks when the chain is halted.
      For application that wants this behaviour now or in 6.1
      they can do so by adding the `config.active_job.skip_after_callbacks_if_terminated = true`
      in their configuration file.
    bbfab0b3
callbacks.rb 5.5 KB