BetterErrors / better_errors

Better error page for Rack apps
MIT License
6.88k stars 437 forks source link

NameError (wrong local variable name `#$!' for Binding) #326

Open alex88 opened 8 years ago

alex88 commented 8 years ago

I've this code:

begin
  response = RestClient::Request.execute(
    method: :get,
    url: some_url('some'),
    headers: {
      params: { clientId: Settings.some.client_id, some: id },
      'X-TOKENID': some_login_token
    },
    max_redirects: 0
  )
rescue RestClient::MaxRedirectsReached => e
  e.response
  error_here
end
error_here

it's called in an ajax request, I open in a new window http://localhost:3000/__better_errors and I get this:

screen shot 2015-12-17 at 18 13 13

no console on the right (I suppose the cursor to be on the first error_here line. If I click on the second line in the 'Application Frames' it works fine (it's a the beginning of the begin).

The rails CLI outputs:

Started POST "/__better_errors/16de44d8c517e45f/variables" for 127.0.0.1 at 2015-12-17 18:13:12 -0800
** [Raven] Event not sent due to excluded environment: development

NameError (wrong local variable name `#$!' for #<Binding:0x007f875f4c80b8>):
  better_errors (2.1.1) lib/better_errors/stack_frame.rb:73:in `local_variable_get'
  better_errors (2.1.1) lib/better_errors/stack_frame.rb:73:in `block in local_variables'
  better_errors (2.1.1) lib/better_errors/stack_frame.rb:71:in `each'
  better_errors (2.1.1) lib/better_errors/stack_frame.rb:71:in `each_with_object'
  better_errors (2.1.1) lib/better_errors/stack_frame.rb:71:in `local_variables'
  (erubis:52:in `render'
  erubis (2.7.0) lib/erubis/evaluator.rb:65:in `eval'
  erubis (2.7.0) lib/erubis/evaluator.rb:65:in `result'
  better_errors (2.1.1) lib/better_errors/error_page.rb:30:in `render'
  better_errors (2.1.1) lib/better_errors/error_page.rb:37:in `do_variables'
  better_errors (2.1.1) lib/better_errors/middleware.rb:132:in `internal_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:75:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.1.13) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.1.13) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  railties (4.1.13) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.13) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.1.13) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.1.13) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.13) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.13) lib/rails/rack/logger.rb:20:in `call'
  quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  request_store (1.2.0) lib/request_store/middleware.rb:8:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.1.13) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.5.5) lib/rack/runtime.rb:17:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  activesupport (4.1.13) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.5.5) lib/rack/lock.rb:17:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.1.13) lib/action_dispatch/middleware/static.rb:84:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.5.5) lib/rack/sendfile.rb:112:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  sentry-raven (0.14.0) lib/raven/integrations/rack.rb:54:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  railties (4.1.13) lib/rails/engine.rb:514:in `call'
  railties (4.1.13) lib/rails/application.rb:144:in `call'
  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.5.5) lib/rack/content_length.rb:14:in `call'
  thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process'
  thin (1.5.1) lib/thin/connection.rb:79:in `catch'
  thin (1.5.1) lib/thin/connection.rb:79:in `pre_process'
  thin (1.5.1) lib/thin/connection.rb:54:in `process'
  thin (1.5.1) lib/thin/connection.rb:39:in `receive_data'
  eventmachine (1.0.5) lib/eventmachine.rb:187:in `run_machine'
  eventmachine (1.0.5) lib/eventmachine.rb:187:in `run'
  thin (1.5.1) lib/thin/backends/base.rb:63:in `start'
  thin (1.5.1) lib/thin/server.rb:159:in `start'
  rack (1.5.5) lib/rack/handler/thin.rb:16:in `run'
  rack (1.5.5) lib/rack/server.rb:264:in `start'
  railties (4.1.13) lib/rails/commands/server.rb:69:in `start'
  railties (4.1.13) lib/rails/commands/commands_tasks.rb:81:in `block in server'
  railties (4.1.13) lib/rails/commands/commands_tasks.rb:76:in `tap'
  railties (4.1.13) lib/rails/commands/commands_tasks.rb:76:in `server'
  railties (4.1.13) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
  railties (4.1.13) lib/rails/commands.rb:17:in `<top (required)>'
  bin/rails:4:in `require'
  bin/rails:4:in `<main>'

  Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.13/lib/action_dispatch/middleware/templates/rescues/_source.erb (1.0ms)
  Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.13/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.7ms)
  Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.13/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.3ms)
  Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.13/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (82.2ms)

any clue on what could be?

haileys commented 8 years ago

I think this is a Ruby bug:

>> begin; raise; rescue; local_variables; end
=> [:"\#$!", :__, :_, :_dir_, :_file_, :_ex_, :_pry_, :_out_, :_in_]

#$! is the name of the hidden local variable used to hold the exception.

haileys commented 8 years ago

@alex88 Can you see if https://github.com/charliesome/better_errors/compare/fix-326 fixes this for you?

nickgal commented 8 years ago

Just wanted to chime in and say that the fix worked for me.

alex88 commented 8 years ago

Same here, sorry for the long delay