Allow skipping variable inspection by class name #449
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a new global setting
BetterErrors.ignored_classes
that will skip inspecting the value of local and instance variables of this type.The default setting ignores action dispatch request and response instances, which are usually not printed anyways due to exceeding the limit of
BetterErrors.maximum_variable_inspect_size
, but also avoidsall the memory allocations and database queries that are triggered by calling
#inspect
on variables.The default setting was chosen to avoid excessive database queries for unloaded relations, because both the
ActionDispatch::Request
and theActionDispatch::Response
objects hold many references to the controller instance, causing the same instance variables to be inspected over and over again.(See rails/rails#38445 for details.)
This is a safer alternative to the undocumented setting
BetterErrors.ignored_instance_variables
, which could be set to[:@_request, :@_response]
for Rails. It also doesn't completely hide the variables, but instead shows a message why the value was omitted, similar tomaximum_variable_inspect_size
.