devise icon indicating copy to clipboard operation
devise copied to clipboard

Timeoutable doesn't work with rails 4.1.0.pre1

Open lejoko opened this issue 12 years ago • 18 comments

Hi,

I built the rails 4.1.0 example application "Devise and Rails" that is on https://github.com/plataformatec/devise/wiki/Example-Applications

If I add :timeoutable to the user model of this app, log in the app and try to navigate, I get an "ArgumentError comparison of String with ActiveSupport::TimeWithZone failed"

Apparently in lib/devise/hooks/timeoutable.rb around line 28:

last_request_at = warden.session(scope)['last_request_at']

returns a string instead of a Time.

Have a nice day.

lejoko avatar Mar 13 '14 13:03 lejoko

I tried the rails-devise app as you mentioned but couldn't replicate the comparison error - timeout worked just fine. Could you provide more information about the error and specially on how to replicate it with a fresh app?

Thanks!

lucasmazza avatar Mar 14 '14 21:03 lucasmazza

Ok, I had a look at it. I tried it with an app as bare as possible. It runs fine with ruby 2.0 but crashes with ruby 1.9.3.

lejoko avatar Mar 17 '14 09:03 lejoko

This is an issue that has been fixed in Devise master since Rails changes the default session serializer.

josevalim avatar Mar 24 '14 09:03 josevalim

I'm having the same issue with Rails 4.1.1, Devise master (downloaded from github today) and Ruby 1.9.3. The problem is triggered by a call to user_signed_in? in my layout. Taking out timeoutable fixes the problem.

Here's a stacktrace:

/home/michael/.rvm/gems/ruby-1.9.3-p448@wecom/bundlerdevise (08d8591dfd78) lib/devise/models/timeoutable.rb:30:in `<='
/home/michael/.rvm/gems/ruby-1.9.3-p448@wecom/bundlerdevise (08d8591dfd78) lib/devise/models/timeoutable.rb:30:in `timedout?'
/home/michael/.rvm/gems/ruby-1.9.3-p448@wecom/bundlerdevise (08d8591dfd78) lib/devise/hooks/timeoutable.rb:19:in `block in <top (required)>'
warden (1.2.3) lib/warden/hooks.rb:14:in `call'
warden (1.2.3) lib/warden/hooks.rb:14:in `block in _run_callbacks'
warden (1.2.3) lib/warden/hooks.rb:9:in `each'
warden (1.2.3) lib/warden/hooks.rb:9:in `_run_callbacks'
warden (1.2.3) lib/warden/manager.rb:53:in `_run_callbacks'
warden (1.2.3) lib/warden/proxy.rb:179:in `set_user'
warden (1.2.3) lib/warden/proxy.rb:217:in `user'
warden (1.2.3) lib/warden/proxy.rb:318:in `_perform_authentication'
warden (1.2.3) lib/warden/proxy.rb:104:in `authenticate'
/home/michael/.rvm/gems/ruby-1.9.3-p448@wecom/bundlerdevise (08d8591dfd78) lib/devise/controllers/helpers.rb:58:in `current_user'
/home/michael/.rvm/gems/ruby-1.9.3-p448@wecom/bundlerdevise (08d8591dfd78) lib/devise/controllers/helpers.rb:54:in `user_signed_in?'
actionpack (4.1.1) lib/abstract_controller/helpers.rb:70:in `user_signed_in?'
actionview (4.1.1) lib/action_view/template.rb:145:in `block in render'
activesupport (4.1.1) lib/active_support/notifications.rb:161:in `instrument'
actionview (4.1.1) lib/action_view/template.rb:339:in `instrument'
actionview (4.1.1) lib/action_view/template.rb:143:in `render'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:67:in `render_with_layout'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionview (4.1.1) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.1.1) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.1.1) lib/action_view/rendering.rb:99:in `_render_template'
actionpack (4.1.1) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.1.1) lib/action_view/rendering.rb:82:in `render_to_body'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.1.1) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
actionpack (4.1.1) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.1.1) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/home/michael/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
activesupport (4.1.1) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.1) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
bullet (4.9.0) lib/bullet/rack.rb:10:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.1) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.2) lib/thin/connection.rb:84:in `catch'
thin (1.6.2) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.2) lib/thin/connection.rb:53:in `process'
thin (1.6.2) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.6.2) lib/thin/backends/base.rb:73:in `start'
thin (1.6.2) lib/thin/server.rb:162:in `start'
rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
rack (1.5.2) lib/rack/server.rb:264:in `start'
railties (4.1.1) lib/rails/commands/server.rb:69:in `start'
railties (4.1.1) lib/rails/commands/commands_tasks.rb:81:in `block in server'
railties (4.1.1) lib/rails/commands/commands_tasks.rb:76:in `tap'
railties (4.1.1) lib/rails/commands/commands_tasks.rb:76:in `server'
railties (4.1.1) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
railties (4.1.1) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:8:in `require'
bin/rails:8:in `<top (required)>'
spring (1.1.2) lib/spring/client/rails.rb:27:in `load'
spring (1.1.2) lib/spring/client/rails.rb:27:in `call'
spring (1.1.2) lib/spring/client/command.rb:7:in `call'
spring (1.1.2) lib/spring/client.rb:26:in `run'
spring (1.1.2) bin/spring:48:in `<top (required)>'
spring (1.1.2) lib/spring/binstub.rb:11:in `load'
spring (1.1.2) lib/spring/binstub.rb:11:in `<top (required)>'
bin/spring:16:in `require'
bin/spring:16:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'

mvdamme avatar May 24 '14 10:05 mvdamme

I'm having the exact same issue as @mvdamme. I'm using Ruby 1.9.3, Rails 4.1.1 and Devise master.

I get the exact same error. This issue is not fixed...

asgeo1 avatar Jun 17 '14 01:06 asgeo1

Also having this exact same issue

"comparison of String with ActiveSupport::TimeWithZone failed"

in devise.rb: config.timeout_in = 30.minutes

if I remove timeoutable it works just fine, using devise master and devise_ldap_Authenticatable

rails 4.1.1, rails 1.9.3p545

tsdragon avatar Jul 03 '14 14:07 tsdragon

Could you guys please test out this branch and see how it works? I haven't pushed this to master since the fix is pretty hackish and we don't have specific tests for how the session serializer upgrade will work.

lucasmazza avatar Jul 03 '14 14:07 lucasmazza

The suggested branch (lm-timeoutable-fix) solves the problem for me. Tested using Ruby 1.9.3 and Rails versions 4.1.1 and 4.1.4. Thanks for looking into this!

mvdamme avatar Jul 03 '14 18:07 mvdamme

Right, I'll see to get this into master and remove that branch anytime soon.

lucasmazza avatar Jul 03 '14 19:07 lucasmazza

This solved my problem when running Rails 4.1.1 and jruby 1.7.13

zachallett avatar Jul 08 '14 17:07 zachallett

@lucasmazza I see "Silence Warning Regarding Use of Splat" updated on master 7 days ago. and branch lm-timeoutable-fix was last updated 15 days ago ... The issue still exists with the master branch ... what would be the possible effects that can occur ?

And are there any possibilities to get this code updated on master soon ??

nikunj0407 avatar Jul 18 '14 09:07 nikunj0407

:+1: seeing the issue as well

reustmd avatar Jul 21 '14 03:07 reustmd

I am still seeing this issue when I try to use "Timeoutable". Any word of when this'll get into the master branch?

Thanks!

Henry-L avatar Aug 05 '14 13:08 Henry-L

Finally pushed this to master @ eb9db7ba3a552ed410b20f1040e167569838b068 gonna cut a new release today/later this week.

lucasmazza avatar Aug 05 '14 17:08 lucasmazza

We're using master for now:

-gem 'devise'
+gem 'devise', git: 'git://github.com/plataformatec/devise.git' # TODO: Once the next release after 3.2.4 is available, revert this to just plain old "gem 'devise'" and run `bundle update devise` again

We look forward to the next release. Thanks!

m5rk avatar Aug 12 '14 14:08 m5rk

Sorry for the delay, but 3.3.0 is out :tada: :tada: :tada:

lucasmazza avatar Aug 13 '14 16:08 lucasmazza

Thanks everybody!

Henry-L avatar Aug 14 '14 19:08 Henry-L

Updating to Devise 3.3 fixed the issue for me. Thank you. :+1:

reggieb avatar Feb 16 '15 11:02 reggieb