medusa-project / book-tracker

Medusa Book Tracker
0 stars 0 forks source link

Rescue ActionController::Live::ClientDisconnected in BooksController.index() #41

Closed adolski closed 11 months ago

adolski commented 11 months ago

Below is an error email I received from the Book Tracker. I get these every once in a while. The cause is when a client is downloading an XML export and closes the connection before it has fully delivered. This is not a big deal and we don't want to receive an email whenever it happens. Instead we should just rescue the error and ignore it.

Error on https://book-tracker.library.illinois.edu/books.xml
Class:   ActionController::Live::ClientDisconnected
Message: client disconnected
Time:    2023-12-07T08:24:17+00:00

Stack Trace:
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/live.rb:190:in `write'
/app/app/controllers/books_controller.rb:205:in `block (5 levels) in index'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/relation/batches.rb:82:in `each'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/relation/batches.rb:82:in `block in find_each'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/relation/batches.rb:158:in `block in find_in_batches'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/relation/batches.rb:396:in `block in batch_on_unloaded_relation'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/relation/batches.rb:372:in `loop'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/relation/batches.rb:372:in `batch_on_unloaded_relation'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/relation/batches.rb:269:in `in_batches'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/relation/batches.rb:157:in `find_in_batches'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/relation/batches.rb:81:in `find_each'
/app/app/controllers/books_controller.rb:205:in `block (4 levels) in index'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/query_cache.rb:83:in `uncached'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/query_cache.rb:21:in `uncached'
/app/app/controllers/books_controller.rb:204:in `block (3 levels) in index'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/live.rb:354:in `send_stream'
/app/app/controllers/books_controller.rb:202:in `block (2 levels) in index'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/mime_responds.rb:214:in `respond_to'
/app/app/controllers/books_controller.rb:172:in `index'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/usr/local/bundle/gems/actionpack-7.1.1/lib/abstract_controller/base.rb:224:in `process_action'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/rendering.rb:165:in `process_action'
/usr/local/bundle/gems/actionpack-7.1.1/lib/abstract_controller/callbacks.rb:259:in `block in process_action'
/usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
/usr/local/bundle/gems/actiontext-7.1.1/lib/action_text/rendering.rb:23:in `with_renderer'
/usr/local/bundle/gems/actiontext-7.1.1/lib/action_text/engine.rb:69:in `block (4 levels) in <class:Engine>'
/usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/callbacks.rb:130:in `instance_exec'
/usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/callbacks.rb:130:in `block in run_callbacks'
/usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/callbacks.rb:141:in `run_callbacks'
/usr/local/bundle/gems/actionpack-7.1.1/lib/abstract_controller/callbacks.rb:258:in `process_action'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/rescue.rb:25:in `process_action'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/instrumentation.rb:74:in `block in process_action'
/usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/notifications.rb:208:in `instrument'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/instrumentation.rb:73:in `process_action'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/params_wrapper.rb:261:in `process_action'
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/railties/controller_runtime.rb:32:in `process_action'
/usr/local/bundle/gems/actionpack-7.1.1/lib/abstract_controller/base.rb:160:in `process'
/usr/local/bundle/gems/actionview-7.1.1/lib/action_view/rendering.rb:40:in `process'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/live.rb:291:in `block (2 levels) in process'
/usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/concurrency/share_lock.rb:162:in `sharing'
/usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/dependencies/interlock.rb:37:in `running'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/live.rb:282:in `block in process'
/usr/local/bundle/gems/actionpack-7.1.1/lib/action_controller/metal/live.rb:368:in `block in new_controller_thread'
gaurijo commented 11 months ago

Does this error also occur with csv export or is it exclusive to xml? I sent up a PR but it only handles the rescue for the XML format.

adolski commented 11 months ago

It's possible, but I don't know--could you investigate?