Skip to content

#shush_backtraces doesn't clean the backtrace_locations #739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
amomchilov opened this issue May 2, 2025 · 0 comments · May be fixed by #740
Open

#shush_backtraces doesn't clean the backtrace_locations #739

amomchilov opened this issue May 2, 2025 · 0 comments · May be fixed by #740

Comments

@amomchilov
Copy link

amomchilov commented May 2, 2025

The Spring::Application#shush_backtraces method strips out Spring stackframes from the exception's backtrace, but not its backtrace_locations:

$!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?

This causes at least 2 issues:

  1. The backtrace and backtrace_locations become out of sync, and only when running in Spring.
  2. It breaks the downstream behaviour of ActiveSupport::ErrorReporter, whose #report method will clean itself off the top of the stack. Since the top of the stack will be these 2 Spring frames, its logic won't remove any of the frames.

Example

#!/opt/rubies/3.4.2/bin/ruby

begin
 raise
rescue => e
end

puts "\nbacktrace:"
puts e.backtrace.first(2)

puts "\nbacktrace_locations:"
puts e.backtrace_locations.first(4)

Output (truncated):

$ bundle exec rails runner demo.rb
Running via Spring preloader in process 33573
running spring after_fork

backtrace
.../demo.rb:4:in '<main>'
.../gems/rails-8b00d0985f88/railties/lib/rails/commands/runner/runner_command.rb:44:in 'Kernel.load'

backtrace_locations
.../gems/spring-4.2.1/lib/spring/application.rb:313:in 'Method#call'
.../gems/spring-4.2.1/lib/spring/application.rb:313:in 'block (2 levels) in Kernel#shush_backtraces'
.../demo.rb:4:in '<main>'
.../gems/rails-8b00d0985f88/railties/lib/rails/commands/runner/runner_command.rb:44:in 'Kernel.load'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant