BetterErrors / better_errors

Better error page for Rack apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Broken with ruby 2.5 and binding_of_caller

ttanimichi opened this issue · comments

$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]

with binding_of_caller

image

without binding_of_caller

image

Reproducing the bug

https://github.com/ttanimichi/myapp20171229/tree/better_errors

This commit has reproduced this bug.

Looks like binding_of_caller with Ruby 2.5 might be no problem. CI of binding_of_caller with Ruby 2.5 are passing. banister/binding_of_caller#68

I'm seeing the same problem Ruby 2.5.0. Once I remove the binding_of_caller gem the track shows back up

Same issue. Ruby 2.5.0, Rails 5.4.1, binding_of_caller 0.7.3

Removed binding_of_caller from development group in Gemfile, rebundled. Works now.

Kernel.binding.callers return nothing with 2.5.0 in better_errors context, which seems to screw up the backtrace.

# lib/better_errors/exception_extension.rb
def set_backtrace(*)
  if caller_locations.none? { |loc| loc.path == __FILE__ }
    @__better_errors_bindings_stack = ::Kernel.binding.callers.drop(1)
  end

  super
end

It was binding_of_caller related, i did a pull request banister/binding_of_caller#69 which seems to work perfeclty...
gem 'binding_of_caller', github: 'D1ceWard/binding_of_caller' for using it before pull request merge.
EDIT: OP can close this issue, fix merged in v0.8 of banister/binding_of_caller, just update your bundle

Can anyone else here confirm @d1ceward's fix works? 😄

Also had this with ruby 2.5.1 but updating to binding_of_caller 0.8.0 fixed it.

Note that binding_of_caller induces other bugs in development due to this Ruby 2.5.3 bug: https://bugs.ruby-lang.org/issues/15105

Consider switching to binding_ninja? https://github.com/joker1007/binding_ninja

@stanhu any hint in how to make binding_ninja works with better_errors? I'm trying, but it's too much deep for my knowledge. 😢

For me it's not working with ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux], Rails 6.0.0.alpha and binding_of_caller-0.8.0

Just discovered that it works, even with ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]. My problem is with a specific scenario. I bundle open the trestle gem and inserted a raise to inspect some variables. In this case I get the following error:

00:23:25 web.1      | Started POST "/admin/__better_errors/50c95030d470e258/variables" for ::1 at 2019-02-09 00:23:25 -0200
00:23:26 web.1      |   
00:23:26 web.1      | TypeError (no implicit conversion of nil into String):
00:23:26 web.1      |   
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:111:in `escapeHTML'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:111:in `rescue in inspect_value'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:107:in `inspect_value'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:94:in `block in render'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:93:in `each'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:93:in `render'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:30:in `eval'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:30:in `render'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:37:in `do_variables'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/middleware.rb:137:in `internal_call'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/middleware.rb:75:in `better_errors_call'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/middleware.rb:57:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:30:in `call'
00:23:26 web.1      | web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
00:23:26 web.1      | web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
00:23:26 web.1      | web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
00:23:26 web.1      | web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/railties/lib/rails/rack/logger.rb:38:in `call_app'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/railties/lib/rails/rack/logger.rb:26:in `block in call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/activesupport/lib/active_support/tagged_logging.rb:80:in `block in tagged'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/activesupport/lib/active_support/tagged_logging.rb:28:in `tagged'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/activesupport/lib/active_support/tagged_logging.rb:80:in `tagged'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/railties/lib/rails/rack/logger.rb:26:in `call'
00:23:26 web.1      | sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/request_id.rb:27:in `call'
00:23:26 web.1      | rack (2.0.6) lib/rack/method_override.rb:22:in `call'
00:23:26 web.1      | rack (2.0.6) lib/rack/runtime.rb:22:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/executor.rb:14:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/static.rb:126:in `call'
00:23:26 web.1      | rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
00:23:26 web.1      | webpacker (3.5.5) lib/webpacker/dev_server_proxy.rb:22:in `perform_request'
00:23:26 web.1      | rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/railties/lib/rails/engine.rb:524:in `call'
00:23:26 web.1      | puma (3.12.0) lib/puma/configuration.rb:225:in `call'
00:23:26 web.1      | puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
00:23:26 web.1      | puma (3.12.0) lib/puma/server.rb:472:in `process_client'
00:23:26 web.1      | puma (3.12.0) lib/puma/server.rb:332:in `block in run'
00:23:26 web.1      | puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
00:23:26 web.1      | Error occurred while parsing request parameters.
00:23:26 web.1      | Contents:
00:23:26 web.1      | 
00:23:26 web.1      |