# Message Bus не работает при изменении настройки пользователя «Пропустить советы и значки для новых пользователей»

**URL:** https://meta.discourse.org/t/message-bus-fail-when-changing-skip-new-user-onboarding-tips-and-badges-user-setting/264019
**Category:** Bug
**Created:** [05.Май.2023 21:34:54 UTC](https://meta.discourse.org/t/message-bus-fail-when-changing-skip-new-user-onboarding-tips-and-badges-user-setting/264019 "2023-05-05T21:34:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [05.Май.2023 21:34:54 UTC](https://meta.discourse.org/t/message-bus-fail-when-changing-skip-new-user-onboarding-tips-and-badges-user-setting/264019/1 "2023-05-05T21:34:54Z")

</div>

Для воспроизведения:

1. Перейдите по адресу [meta.discourse.org/my/preferences/interface](https://meta.discourse.org/my/preferences/interface)

2. Откройте консоль вашего браузера

3. Переключите опцию «Пропустить советы по первичной настройке и значки для новых пользователей» и нажмите «Сохранить»

В консоли появится ошибка:

```plaintext
MESSAGE BUS FAIL: callback /user-tips/2770 вызвал исключение onMessage/<@https://global.discourse-cdn.com/meta/assets/discourse-aca223ea4cd01ddb1a6f180395955d62c82cdfd63a0f788938e09aae5af55f55.br.js:4216:653
onMessage@https://global.discourse-cdn.com/meta/assets/discourse-aca223ea4cd01ddb1a6f180395955d62c82cdfd63a0f788938e09aae5af55f55.br.js:4216:597
U.prototype._run@https://global.discourse-cdn.com/meta/assets/vendor-33e08796a908852ea6a675c57d6711f18f2428795ec0f2548e4df9733e003014.br.js:4446:94
U.prototype._join@https://global.discourse-cdn.com/meta/assets/vendor-33e08796a908852ea6a675c57d6711f18f2428795ec0f2548e4df9733e003014.br.js:4445:256
U.prototype.join@https://global.discourse-cdn.com/meta/assets/vendor-33e08796a908852ea6a675c57d6711f18f2428795ec0f2548e4df9733e003014.br.js:4408:13
p@https://global.discourse-cdn.com/meta/assets/vendor-33e08796a908852ea6a675c57d6711f18f2428795ec0f2548e4df9733e003014.br.js:2570:63
m/<@https://global.discourse-cdn.com/meta/assets/vendor-33e08796a908852ea6a675c57d6711f18f2428795ec0f2548e4df9733e003014.br.js:2573:8
b@https://global.discourse-cdn.com/meta/assets/chunk.703.1bbc722b2533c9d7510a-e77869e990640cdc164a270bdea9a4b9995366c02a371c298741dcb9d72003ca.br.js:833:7
w@https://global.discourse-cdn.com/meta/assets/chunk.703.1bbc722b2533c9d7510a-e77869e990640cdc164a270bdea9a4b9995366c02a371c298741dcb9d72003ca.br.js:833:274
P@https://global.discourse-cdn.com/meta/assets/chunk.703.1bbc722b2533c9d7510a-e77869e990640cdc164a270bdea9a4b9995366c02a371c298741dcb9d72003ca.br.js:846:6
r</k/onProgressListener/t.onprogress@https://global.discourse-cdn.com/meta/assets/chunk.703.1bbc722b2533c9d7510a-e77869e990640cdc164a270bdea9a4b9995366c02a371c298741dcb9d72003ca.br.js:849:163
EventHandlerNonNull*onProgressListener@https://global.discourse-cdn.com/meta/assets/chunk.703.1bbc722b2533c9d7510a-e77869e990640cdc164a270bdea9a4b9995366c02a371c298741dcb9d72003ca.br.js:849:44
xhr@https://global.discourse-cdn.com/meta/assets/chunk.703.1bbc722b2533c9d7510a-e77869e990640cdc164a270bdea9a4b9995366c02a371c298741dcb9d72003ca.br.js:850:27
send@https://global.discourse-cdn.com/meta/assets/vendor-33e08796a908852ea6a675c57d6711f18f2428795ec0f2548e4df9733e003014.br.js:468:67
ajax@https://global.discourse-cdn.com/meta/assets/vendor-33e08796a908852ea6a675c57d6711f18f2428795ec0f2548e4df9733e003014.br.js:448:12
l@https://global.discourse-cdn.com/meta/assets/discourse-aca223ea4cd01ddb1a6f180395955d62c82cdfd63a0f788938e09aae5af55f55.br.js:4065:10
initialize/n.ajax@https://global.discourse-cdn.com/meta/assets/discourse-aca223ea4cd01ddb1a6f180395955d62c82cdfd63a0f788938e09aae5af55f55.br.js:4069:531
k@https://global.discourse-cdn.com/meta/assets/chunk.703.1bbc722b2533c9d7510a-e77869e990640cdc164a270bdea9a4b9995366c02a371c298741dcb9d72003ca.br.js:848:66
n@https://global.discourse-cdn.com/meta/assets/chunk.703.1bbc722b2533c9d7510a-e77869e990640cdc164a270bdea9a4b9995366c02a371c298741dcb9d72003ca.br.js:857:25
r</start/e.onVisibilityChange@https://global.discourse-cdn.com/meta/assets/chunk.703.1bbc722b2533c9d7510a-e77869e990640cdc164a270bdea9a4b9995366c02a371c298741dcb9d72003ca.br.js:858:166
callback@https://global.discourse-cdn.com/meta/assets/discourse-aca223ea4cd01ddb1a6f180395955d62c82cdfd63a0f788938e09aae5af55f55.br.js:4067:192
d@https://global.discourse-cdn.com/meta/assets/discourse-aca223ea4cd01ddb1a6f180395955d62c82cdfd63a0f788938e09aae5af55f55.br.js:5743:26
p@https://global.discourse-cdn.com/meta/assets/discourse-aca223ea4cd01ddb1a6f180395955d62c82cdfd63a0f788938e09aae5af55f55.br.js:5743:92
m@https://global.discourse-cdn.com/meta/assets/discourse-aca223ea4cd01ddb1a6f180395955d62c82cdfd63a0f788938e09aae5af55f55.br.js:5743:129

```

Переключатель, похоже, работает нормально, несмотря на ошибку, поэтому неясно, является ли это реальной проблемой.

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [06.Май.2023 00:51:18 UTC](https://meta.discourse.org/t/message-bus-fail-when-changing-skip-new-user-onboarding-tips-and-badges-user-setting/264019/2 "2023-05-06T00:51:18Z")

</div>

> <https://github.com/discourse/discourse/blob/83f1a13374bc3906919744f48071511c12912df9/app/assets/javascripts/discourse/app/initializers/user-tips.js#L41-L46>

Хорошей идеей будет сначала проверить `this.site.user_tips`. 😄

```js
  if (this.site.user_tips) {
    (seenUserTips || []).forEach((userTipId) => {
      this.currentUser.hideUserTipForever(
        Object.keys(this.site.user_tips).find(
          (id) => this.site.user_tips[id] === userTipId
        )
      );
    });
  }

```

Полагаю, MessageBus отправляется после завершения сохранения; именно поэтому это работает. Это не вредит и не должно быть реальной проблемой.

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [10.Май.2023 19:17:59 UTC](https://meta.discourse.org/t/message-bus-fail-when-changing-skip-new-user-onboarding-tips-and-badges-user-setting/264019/4 "2023-05-10T19:17:59Z")

</div>

> [@Arkshine](#):
>
> Возможно, стоит сначала проверить `this.site.user_tips`. 😄

Технически это значение всегда должно быть установлено. Оно сбрасывается только в том случае, если пользователь заходит на страницу, а администраторы включают подсказки для пользователей уже после этого. По этой причине я считаю, что лучшим решением будет установить `refresh: true` для этой настройки сайта. В любом случае, ваше решение добавляет дополнительную защиту и закрывает пробел между моментом изменения настройки сайта и обновлением страницы.

Спасибо за ваш интерес! Вот исправление:

> <https://github.com/discourse/discourse/pull/21489>
>
> Without refresh, no user tip will be shown and Site.user\_tips is not
> properly p…opulated either.
> 
> The other commit fixes the MessageBus handler until page is refreshed.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [17.Май.2023 00:06:20 UTC](https://meta.discourse.org/t/message-bus-fail-when-changing-skip-new-user-onboarding-tips-and-badges-user-setting/264019/5 "2023-05-17T00:06:20Z")

</div>


