#<Net::OpenTimeout: execution expired>

AI-generated summary

sunjam is troubleshooting a recurring Net::OpenTimeout: execution expired error affecting image uploads on a Discourse forum running version 2.9.0.beta4. The error appears in multiple contexts, including avatar proxying and file downloads, with over 270,000 reported instances as noted in post 3. The stack trace points to Ruby’s net/http library timing out during connection attempts, possibly due to DNS resolution issues. sunjam references a Stack Overflow solution suggesting that adding require 'resolv-replace' at the start of the code may resolve the issue, citing a known problem with certain libc versions and DNS handling in Ruby. The forum has several active plugins, including discourse-checklist, discourse-solved, and docker_manager, though the styleguide plugin is disabled. The issue appears to impact multiple users, with similar reports noted on Meta Discourse linked in post 1.

Helping @rakekniven sort out forum performance issues and users are no longer able to upload images. This error has been cropping up a lot. Seems this person is also having similar errors and is also unable to upload images.

Plugins on the forum
  • Canned Replies
  • discourse-checklist
  • discourse-legal-tools
  • discourse-solved
  • docker_manager
  • styleguide - disabled
Message (661 copies reported) on  2.9.0.beta4 

#<Net::OpenTimeout: execution expired>

Backtrace

/usr/local/lib/ruby/2.7.0/net/http.rb:960:in initialize' /usr/local/lib/ruby/2.7.0/net/http.rb:960:in open’
/usr/local/lib/ruby/2.7.0/net/http.rb:960:in block in connect' /usr/local/lib/ruby/2.7.0/timeout.rb:105:in timeout’
/usr/local/lib/ruby/2.7.0/net/http.rb:958:in connect' /usr/local/lib/ruby/2.7.0/net/http.rb:943:in do_start’
/usr/local/lib/ruby/2.7.0/net/http.rb:932:in start' /usr/local/lib/ruby/2.7.0/net/http.rb:606:in start’
/var/www/discourse/lib/final_destination.rb:515:in safe_session' /var/www/discourse/lib/final_destination.rb:455:in safe_get’

Upload error

Net::OpenTimeout : execution expired

Message (273757 copies reported)

Failed to process hijacked response correctly : Net::OpenTimeout : execution expired

Backtrace

/usr/local/lib/ruby/2.7.0/net/http.rb:960:in initialize' /usr/local/lib/ruby/2.7.0/net/http.rb:960:in open’
/usr/local/lib/ruby/2.7.0/net/http.rb:960:in block in connect' /usr/local/lib/ruby/2.7.0/timeout.rb:105:in timeout’
/usr/local/lib/ruby/2.7.0/net/http.rb:958:in connect' /usr/local/lib/ruby/2.7.0/net/http.rb:943:in do_start’
/usr/local/lib/ruby/2.7.0/net/http.rb:932:in start' /usr/local/lib/ruby/2.7.0/net/http.rb:606:in start’
/var/www/discourse/lib/final_destination.rb:515:in safe_session' /var/www/discourse/lib/final_destination.rb:455:in safe_get’
/var/www/discourse/lib/final_destination.rb:147:in get' /var/www/discourse/lib/file_helper.rb:68:in download’
/var/www/discourse/app/controllers/user_avatars_controller.rb:158:in proxy_avatar' /var/www/discourse/app/controllers/user_avatars_controller.rb:51:in block in show_proxy_letter’
/var/www/discourse/lib/hijack.rb:56:in instance_eval' /var/www/discourse/lib/hijack.rb:56:in block in hijack’
/var/www/discourse/lib/scheduler/defer.rb:94:in block in do_work' rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:80:in with_connection’
/var/www/discourse/lib/scheduler/defer.rb:89:in do_work' /var/www/discourse/lib/scheduler/defer.rb:79:in block (2 levels) in start_thread’

Env

Found this on stackoverflow for resolving the issue in Ruby:

It seems to be a problem with certain versions of libc which resolve DNS routes. After spending couple hours to search solution you just need to add require 'resolv-replace' at the beginning of your code.

More information: Use Ruby DNS resolver to handle DNS timeout in Net::HTTP by pranas · Pull Request #597 · ruby/ruby · GitHub

Hope this help somebody in the future.