From 1b8be069e5c43053b2b31b2e4f81a0d6b5fe2066 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 16 Oct 2019 14:44:48 +0100 Subject: [PATCH] DEV: Disable better_errors when developing with more than one worker (#8201) From the better_errors README: > Better Errors works by leaving a lot of context in server process memory. If you're using a web server that runs multiple "workers" it's likely that a second request (as happens when you click on a stack frame) will hit a different worker. That worker won't have the necessary context in memory, and you'll see a Session Expired message. --- config/environments/development.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/environments/development.rb b/config/environments/development.rb index 6c080046d7a..473347772f7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -40,6 +40,11 @@ Discourse::Application.configure do BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP'] + if defined?(Unicorn) && ENV["UNICORN_WORKERS"].to_i != 1 + # BetterErrors doesn't work with multiple unicorn workers. Disable it to avoid confusion + Rails.configuration.middleware.delete BetterErrors::Middleware + end + config.load_mini_profiler = true if hosts = ENV['DISCOURSE_DEV_HOSTS'] config.hosts.concat(hosts.split(","))