# Anonymous mode not working

**URL:** https://meta.discourse.org/t/anonymous-mode-not-working/159869
**Category:** Bug
**Tags:** anonymous-mode
**Created:** [August 5, 2020, 7:43am UTC](https://meta.discourse.org/t/anonymous-mode-not-working/159869 "2020-08-05T07:43:46Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [August 5, 2020, 7:43am UTC](https://meta.discourse.org/t/anonymous-mode-not-working/159869/1 "2020-08-05T07:43:46Z")

</div>

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

```plaintext
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
```

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 5, 2020, 9:19am UTC](https://meta.discourse.org/t/anonymous-mode-not-working/159869/2 "2020-08-05T09:19:49Z")

</div>

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

> <https://github.com/discourse/discourse/blob/main/app/services/anonymous_shadow_creator.rb#L34>

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 5, 2020, 10:49am UTC](https://meta.discourse.org/t/anonymous-mode-not-working/159869/3 "2020-08-05T10:49:02Z")

</div>

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

[https://github.com/discourse/discourse/pull/10374](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?

---

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [August 5, 2020, 2:21pm UTC](https://meta.discourse.org/t/anonymous-mode-not-working/159869/4 "2020-08-05T14:21:07Z")

</div>

That fixed it for me, thank you @j.jaffeux 👍

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 5, 2020, 2:24pm UTC](https://meta.discourse.org/t/anonymous-mode-not-working/159869/5 "2020-08-05T14:24:06Z")

</div>

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 👍

---

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [August 5, 2020, 2:31pm UTC](https://meta.discourse.org/t/anonymous-mode-not-working/159869/6 "2020-08-05T14:31:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 5, 2020, 2:34pm UTC](https://meta.discourse.org/t/anonymous-mode-not-working/159869/7 "2020-08-05T14:34:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 9, 2020, 2:34pm UTC](https://meta.discourse.org/t/anonymous-mode-not-working/159869/8 "2020-08-09T14:34:40Z")

</div>

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