Module: ShopifyCLI::Theme::DevServer::WEBrickGenericServerThreadJoinWithTimeout
- Defined in:
- lib/shopify_cli/theme/dev_server/web_server.rb
Overview
WEBrick will sometimes cause a fatal deadlock error on shutdown. The error happens because ‘Thread#join` is called without a timeout argument. We monkey-patch WEBrick to call `Thread#join(timeout)` before the existing `Thread#join`.
Instance Method Summary collapse
-
#cleanup_listener ⇒ Object
Hook into a method called right before the threads are shutdown.
Instance Method Details
#cleanup_listener ⇒ Object
Hook into a method called right before the threads are shutdown.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/shopify_cli/theme/dev_server/web_server.rb', line 15 def cleanup_listener # Force a Thread#join with a timeout to prevent any deadlock error on stop Thread.list.each do |thread| next unless thread[:WEBrickThread] thread.join(2) # Prevent the `join` call without a timeout inside WEBrick. thread[:WEBrickThread] = false end super end |