Anonymous mode not working

I’ve just tried using anon mode on my Discourse instance and when I click to enter, nothing happens.

This is the error I see in the JS logs:

iPhone / Safari

Message (12 copies reported)

NoMethodError (undefined method `<' for nil:NilClass)
/var/www/discourse/app/services/anonymous_shadow_creator.rb:34:in `get'

Backtrace

/var/www/discourse/app/services/anonymous_shadow_creator.rb:34:in `get'
/var/www/discourse/app/services/anonymous_shadow_creator.rb:11:in `get'
/var/www/discourse/app/controllers/users_controller.rb:863:in `toggle_anon'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.2/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.2/lib/abstract_controller/base.rb:195:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.2/lib/action_controller/metal/rendering.rb:30:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.2/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:135:in `run_callbacks'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.2/lib/abstract_controller/callbacks.rb:41:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.2/lib/action_controller/metal/rescue.rb:22:in `process_action'

Env

HTTP HOSTS: se23.life
1 Like

Seems like it might happen if the shadowed user has never posted anything?

https://github.com/discourse/discourse/blob/master/app/services/anonymous_shadow_creator.rb#L34

3 Likes

Not sure what would be the correct fix here, I could do this:

https://github.com/discourse/discourse/pull/10374

But the real question is: how someone who has post_count/topic_count doesn’t have a last_posted_at ? I didn’t dig, but it seems like it shouldn’t be possible?

8 Likes

That fixed it for me, thank you @joffreyjaffeux :+1:

3 Likes

If you have some time to investigate how this user is in this state, could be helpful, but no worries if you can’t.

Thanks for report and update :+1:

2 Likes

Very peculiar - it was me (site admin, user #1). And I would have tested anon mode a while ago, before disabling the feature. I re-enabled the feature today and that’s when I encountered the bug.

1 Like

Hmmm ok thanks. I guess I will classify this into “weird states due to some rare history”… for now at least :smiley:

3 Likes

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.