vendredi 10 juillet 2020

Not cathing the unicorn timeout exception in heroku

This is sample code which i am trying to handle exception from unicorn.

unicron.rb

worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3)
timeout 15
preload_app true

timeout.rb

Rack::Timeout.timeout = 12

Sample code

def create_store
   ActiveRecord::Base.transaction do

     @store = Store.new(params[:store])
     if @store.save!
       sleep 12.3
       InformUserWorker.perform_async(store_id)
     end

   end

   rescue => exception
    exception.backtrace.each { |trace| puts trace }
   rescue Timeout::Error
    puts 'That took too long, exiting...1'
   rescue Rack::Timeout::RequestTimeoutException
    puts 'That took too long, exiting...2'
   rescue Rack::Timeout::RequestTimeoutError
    puts 'That took too long, exiting...3'
   rescue Rack::Timeout::RequestExpiryError
    puts 'That took too long, exiting...4'
end

I am getting code=H13 desc="Connection closed without response" with this sleep 12.3 seconds, and the transaction rollback happens, but none of these exceptions are executing. I have added couple of exception here. Anything goes wrong here?.

Aucun commentaire:

Enregistrer un commentaire