cryo28 / sidekiq_status

Extension to Sidekiq to pass job execution metadata such as status and result back to the client
MIT License
152 stars 53 forks source link

Error in web interface #38

Closed lepek closed 8 years ago

lepek commented 8 years ago

Using Sidekiq 4.1.1 and sidekiq_status 1.1.0, when I go to statuses in the Sidekiq Web, I get this error:

2016-05-23 11:42:02 INFO [request_id:, param_request_id:, user_id: ] Started GET "/sidekiq/statuses" for 127.0.0.1 at 2016-05-23 11:42:02 -0300
App 97245 stderr: 2016-05-23 11:42:02 - SyntaxError - /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sidekiq_status-1.1.0/lib/sidekiq_status/web.rb:54: syntax error, unexpected ';'
App 97245 stderr: ...statuses.each do |container| -; @_out_buf.concat "\n"
App 97245 stderr: ...                               ^
App 97245 stderr: /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sidekiq_status-1.1.0/lib/sidekiq_status/web.rb:73: syntax error, unexpected ';'
App 97245 stderr: ...  ";  if container.killable? -; @_out_buf.concat "\n"
App 97245 stderr: ...                               ^
App 97245 stderr: /Users/mbianculli/.rvm/gems/ruby-2.1.4/gem
App 97245 stderr: s/sidekiq_status-1.1.0/lib/sidekiq_status/web.rb:75: syntax error, unexpected keyword_elsif, expecting keyword_end
App 97245 stderr: ...t_buf.concat "        ";  elsif container.kill_requested? -;...
App 97245 stderr: ...                               ^
App 97245 stderr: /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sidekiq_status-1.1.0/lib/sidekiq_status/web.rb:75: syntax error, unexpected ';'
App 97245 stderr: ...if container.kill_requested? -; @_out_buf.concat "\n"
App 97245 stderr: ...                               ^
App 97245 stderr: /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sidekiq_status-1.1.0/lib/sidekiq_status/web.rb:80: syntax error, unexpected ';'
App 97245 stderr: ; @_out_buf.concat "  ";  end -; @_out_buf.concat "\n"
App 97245 stderr:                                 ^
App 97245 stderr: /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sidekiq_status-1.1.0/lib/sidekiq_status/web.rb:81: syntax error, unexpected ';'
App 97245 stderr: ; @_out_buf.concat "  ";  if @statuses.empty? -; @_out_buf.concat "\n"
App 97245 stderr:                                                 ^
App 97245 stderr: /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sidekiq_status-1.1.0/lib/sidekiq_status/web.rb:85: syntax error, unexpected ';'
App 97245 stderr: ; @_out_buf.concat "  ";  end -; @_out_buf.concat "\n"
App 97245 stderr:                                 ^
App 97245 stderr: /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sidekiq_status-1.1.0/lib/sidekiq_status/web.rb:96: syntax error, unexpected keyword_end, expecting end-of-input
App 97245 stderr: end;end;end;end
App 97245 stderr:            ^:
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/tilt-2.0.2/lib/tilt/template.rb:267:in `class_eval'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/tilt-2.0.2/lib/tilt/template.rb:267:in `compile_template_method'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/tilt-2.0.2/lib/tilt/template.rb:230:in `block in compiled_method'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/tilt-2.0.2/lib/tilt/template.rb:229:in `synchronize'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/tilt-2.0.2/lib/tilt/template.rb:229:in `compiled_method'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/tilt-2.0.2/lib/tilt/template.rb:163:in `evaluate'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/tilt-2.0.2/lib/tilt/template.rb:99:in `render'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:823:in `render'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:667:in `erb'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sidekiq_status-1.1.0/lib/sidekiq_status/web.rb:27:in `block in registered'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1611:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1611:in `block in compile!'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `[]'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `block (3 levels) in route!'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:994:in `route_eval'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `block (2 levels) in route!'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1015:in `block in process_route'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1013:in `catch'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1013:in `process_route'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:973:in `block in route!'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:972:in `each'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:972:in `route!'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1085:in `block in dispatch!'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `block in invoke'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `catch'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `invoke'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1082:in `dispatch!'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:907:in `block in call!'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `block in invoke'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `catch'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `invoke'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:907:in `call!'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:895:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-1.6.4/lib/rack/auth/basic.rb:25:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-1.6.4/lib/rack/nulllogger.rb:9:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/show_exceptions.rb:25:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:182:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:2013:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1487:in `block in call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1787:in `synchronize'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/sinatra-1.4.7/lib/sinatra/base.rb:1487:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/routing/mapper.rb:51
App 97245 stderr: :in `serve'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/journey/router.rb:43:in `block in serve'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/journey/router.rb:30:in `each'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/journey/router.rb:30:in `serve'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/routing/route_set.rb:815:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/versionist-1.5.0/lib/versionist/middleware.rb:39:in `_call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/versionist-1.5.0/lib/versionist/middleware.rb:17:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-1.6.4/lib/rack/etag.rb:24:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-1.6.4/lib/rack/conditionalget.rb:25:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/activerecord-4.2.5.1/lib/active_record/query_cache.rb:36:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:377:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/reloader.rb:73:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:38:in `call_app'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:22:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/bundler/gems/nightwatch-d0825b733c50/lib/nightwatch/silenced_logger.rb:19:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/activesupport-4.2.5.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/static.rb:116:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/railties-4.2.5.1/lib/rails/engine.rb:518:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/railties-4.2.5.1/lib/rails/application.rb:165:in `call'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/passenger-5.0.26/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/passenger-5.0.26/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/passenger-5.0.26/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/passenger-5.0.26/src/ruby_supportlib/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads'
App 97245 stderr:   /Users/mbianculli/.rvm/gems/ruby-2.1.4/gems/passenger-5.0.26/src/ruby_supportlib/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
cryo28 commented 8 years ago

@lepek As far as I understand this is not a problem of sidekiq_status. The problem here is that sidekiq_status uses ERB with default settings with enabled trim mode to omit blank lines. Due to some reason in your setup the default ERB mode excludes omit blank lines ending in -%?> modifier, so ERB just fails.

Really there is no strong reason for sidekiq_status to expect such trim mode except for generating more concise output so fixing this should be pretty trivial. However you should rather lookup your code and see what changes ERB trim mode from the default one and whether it is really required.

PS. I believe somebody has reported something similar before, but I cannnot just find this issue now, sorry.

lepek commented 8 years ago

The only thing I can imagine is that some gem is changing the default ERB trim mode, I am not doing it in the app. I will double check. It is the only part in the Sidekiq Web UI that has this issue. I am using rails_api which has some special handling of some of the view libraries, I don't know if that can be the reason. There is a similar issue from 2014 which was solved, according to the reporter, updating Sidekiq. There was also this issue in Sidekiq: https://github.com/mperham/sidekiq/issues/1736

lepek commented 8 years ago

Just for the record, I fixed it money patching the Sidekiq's class. Not the most elegant.

module Sidekiq
  class Web < Sinatra::Base
    set :erb, { trim: '-' }
  end
end
cryo28 commented 8 years ago

@lepek BTW try master branch. It includes 486c0baf0b08044f632317de5dc0ec027847c45e which removes the whitespace trimming.