exception_notification
exception_notification copied to clipboard
ActionDispatch::Cookies::CookieOverflow not reported
I have been using this gem for ages, it’s one of the core gems I could hardly live without, but I trusted it too much. Recently, a customer reported she could not log in. When finally found the error (after I wondered I should have received emails), I checked the logs how many times we had this and I wanted to cry. (We lost thousands of users over the last 3 months because of this.)
See: #29
Anyway, I can easily reproduce it in development.
If I add a line
blablabla
into our sign in method, I receive the email about the NameError.
But if I add this
session[:hello] = [1] * 1000
I see the exception in the browser. No email received.
Yeah, we were close to the 4K cookie limit already, but only a small percentage of the users hit it, for who knows how long.
Rails 4.2.7 ExceptionNotification 4.2.1
It’s configured as:
Rails.application.config.middleware.use ExceptionNotification::Rack, email: {...}
Note: the second spec passes for the wrong behaviour. It should fail as soon as ActionDispatch::Cookies::CookieOverflow is caught and notified about.
require 'rails_helper'
describe 'Exception Notification', type: :request do
##
# Spec whether we receive the emails
#
scenario 'Notifies about exceptions' do
# Spec with multiple errors
exception = [NameError, NoMethodError].sample
# Should not
expect do get root_path end.to_not raise_error
# Should raise
expect_any_instance_of(ApplicationController).to receive(:save_referer) { raise exception }
# Should notify
expect do
expect do get root_path end.to raise_error exception
end.to change { ActionMailer::Base.deliveries.count }.by 1
end
scenario 'Does not notify about ActionDispatch::Cookies::CookieOverflow' do
# Specific exception
exception = ActionDispatch::Cookies::CookieOverflow
# Should raise
expect_any_instance_of(ApplicationController).to receive(:save_referer).and_call_original
# Should but won’t notify
expect do
expect do get root_path cookie_length: ('a' * 5000) end.to raise_error exception
end.to_not change { ActionMailer::Base.deliveries.count }
end
end
def save_referer
session[:requested_url] = request.original_url if session[:requested_url].blank?
end
Got similar problem lately. Any chances of fixing it or help? Rails 5.0.7 ExceptionNotification 4.2.2
Will upgrade
@PeterMozesMerl @zubru I think this is related to the order of the middlewares.
Can you try using something like this?
Rails.application.config.middleware.insert_after ActionDispatch::DebugExceptions, ExceptionNotification::Rack, email: {...}
@EmilioCristalli I had the same issue and inserting the middleware after ActionDispatch::DebugExceptions
like you said has solved it.
Lot of thanks :)