# Cloudflare 或插件导致我的 Discourse 实例故障？

**URL:** https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711
**Category:** Support
**Created:** [2020年四月29日 05:31 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711 "2020-04-29T05:31:57Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年四月29日 05:31 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/1 "2020-04-29T05:31:57Z")

</div>

在我的 Discourse 论坛上，点击通知铃铛图标时，一直显示加载动画。加载菜单中提示“慢一点，该 IP 地址的请求过多”。我正在使用 Cloudflare。

---

<div class="post-metadata">

### Author: ![schleifer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schleifer/32/86416_2.png) [@schleifer](https://meta.discourse.org/u/schleifer)
#### Post date: [2020年四月29日 06:10 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/2 "2020-04-29T06:10:47Z")

</div>

您具体是如何使用 Cloudflare 的？

这是一个非常相关的话题：

> [@Full site CDN acceleration for Discourse](https://meta.discourse.org/t/full-site-cdn-acceleration-for-discourse/21467):
>
> [Fastly](http://www.fastly.com/) , [CloudFlare](https://www.cloudflare.com) and a few other CDNs offer a mode where they accelerate dynamic content. In a nutshell you point your domain IP address at the CDN and the CDN will intelligently decide how to deal with the request. Static content can be easily served from cache Dynamic content can be routed to the site. This provides some advantages over only shipping static assets which is covered in [the CDN howto](https://meta.discourse.org/t/enable-a-cdn-for-your-discourse/14857). You can elect for “[shielding](http://www.fastly.com/products/origin-shield/)” that protects your site from traffic spikes. Dynamic cont…

您是否按照那里的三个步骤进行了操作？

---

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年四月29日 06:42 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/3 "2020-04-29T06:42:27Z")

</div>

> [@schleifer](#):
>
> 你按照那里给出的三个步骤操作了吗？

是的，我操作了，并且在最近的 beta 更新之前一直运行正常。  
目前大部分功能也正常，只是通知出现了问题：它会每隔几秒发起无限次请求。

 ![Screenshot 2020-04-29 at 12.10.58 PM](https://global.discourse-cdn.com/meta/original/3X/d/1/d1fcce98123cee778df24e8e614c59efc060e159.png)

这是我的控制台截图：

 ![Screenshot 2020-04-29 at 12.13.34 PM](https://global.discourse-cdn.com/meta/original/3X/9/a/9a8a3c47bdfea3defb288e27ffb4881a96affeca.png)

这是打开的文件截图：

 ![Screenshot 2020-04-29 at 12.14.48 PM](https://global.discourse-cdn.com/meta/original/3X/6/b/6b6db35db6dc8d3c6c09370421cbad461fd7d9ec.png)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2020年四月29日 23:51 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/4 "2020-04-29T23:51:53Z")

</div>

请禁用 Cloudflare，它正在破坏您的网站。

---

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年五月2日 09:34 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/5 "2020-05-02T09:34:54Z")

</div>

我使用的是 Cloudflare 的免费套餐，并启用了 5 美元的 Cloudflare SSL 订阅。目前没有任何 Cloudflare 功能被启用：Rocket Loader 已关闭，所有其他优化（如代码压缩等）也均已关闭，而像 Railgun 等其他功能在免费套餐中甚至不可用。缓存设置也已配置为尊重现有的源站头部信息。之前一切正常，但我刚刚意识到，我通过访问 `/admin/upgrade` 升级到了 master Git 分支，这可能导致了问题。之后我虽然移除了相关脚本和引用，但系统仍在反复检查通知。目前只有通知功能引发了问题，其他一切运行正常。

我使用 Cloudflare 来分发存储在 Amazon S3 并通过 CloudFront 托管的文件。如果我不使用 Cloudflare，我的成本将会上升。Cloudflare 仅作为 DNS 和 SSL 提供商使用，其优化功能和大部分特性均已关闭，且许多功能在免费套餐中根本不可用。您认为在我的情况下，Cloudflare 仍然是问题的根源吗？

我是否应该尝试重新构建以解决这些问题？

附注：我是 StackOverflow、CodingHorror 博客和 Discourse 的忠实粉丝。致敬 🖖

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2020年五月2日 09:36 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/6 "2020-05-02T09:36:00Z")

</div>

首先尝试禁用 CloudFlare（基本 DNS 除外）作为实验。如果问题消失，这就说明了一些情况。

---

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年五月2日 09:54 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/8 "2020-05-02T09:54:32Z")

</div>

我已禁用 Cloudflare 的橙色云朵模式，并等待浏览器显示 Let’s Encrypt 的 SSL 证书（而非 Cloudflare），以确认内容直接从服务器获取而非经过 Cloudflare。随后我重新构建了项目，但现在点击用户菜单和通知图标时，仍然出现以下错误：

```
Uncaught (in promise) DOMException: Quota exceeded.
_application-977ce16935600e0a620c1ea565154ab68e46f60a9fe0f207139e0f2128dd9474.js:77250 Uncaught TypeError: Cannot read property 'dasherize' of undefined
    at s.itemHtml (_application-977ce16935600e0a620c1ea565154ab68e46f60a9fe0f207139e0f2128dd9474.js:77250)
    at _application-977ce16935600e0a620c1ea565154ab68e46f60a9fe0f207139e0f2128dd9474.js:77390
    at _ember_jquery-d1d89874d5f08a664c68007c6c2eef5e3bb1cbd8058291fce7818d8ef4ded8ca.js:39008
    at t.u.Mixin.create.c.forEach (_ember_jquery-d1d89874d5f08a664c68007c6c2eef5e3bb1cbd8058291fce7818d8ef4ded8ca.js:38995)
    at t.u.Mixin.create.c.map (_ember_jquery-d1d89874d5f08a664c68007c6c2eef5e3bb1cbd8058291fce7818d8ef4ded8ca.js:39007)
    at s.html (_application-977ce16935600e0a620c1ea565154ab68e46f60a9fe0f207139e0f2128dd9474.js:77389)
    at s.value (_application-977ce16935600e0a620c1ea565154ab68e46f60a9fe0f207139e0f2128dd9474.js:80621)
    at s.value (_application-977ce16935600e0a620c1ea565154ab68e46f60a9fe0f207139e0f2128dd9474.js:80371)
    at s (_vendor-7fd29296ee54f8a7ced9508b106a09ec4aae4912ed1cf10eceb7eb2acca03309.js:20669)
    at t.exports (_vendor-7fd29296ee54f8a7ced9508b106a09ec4aae4912ed1cf10eceb7eb2acca03309.js:20652)

```

打开该文件后，显示内容如下：

```
define("discourse/widgets/quick-access-notifications", ["discourse/lib/ajax", "discourse/widgets/widget", "discourse/widgets/quick-access-panel"], function (_ajax, _widget, _quickAccessPanel) {
  "use strict";

  (0, _widget.createWidgetFrom)(_quickAccessPanel.default, "quick-access-notifications", {
    buildKey: function buildKey() {
      return "quick-access-notifications";
    },
    emptyStatePlaceholderItemKey: "notifications.empty",

    markReadRequest: function markReadRequest() {
      return (0, _ajax.ajax)("/notifications/mark-read", { type: "PUT" });
    },
    newItemsLoaded: function newItemsLoaded() {
      if (!this.currentUser.enforcedSecondFactor) {
        this.currentUser.set("unread_notifications", 0);
      }
    },
    itemHtml: function itemHtml(notification) {
      var notificationName = this.site.notificationLookup[notification.notification_type];

      return this.attach(notificationName.dasherize() + "-notification-item", notification, {}, { fallbackWidgetName: "default-notification-item" });
    },
    findNewItems: function findNewItems() {
      return this._findStaleItemsInStore().refresh();
    },
    showAllHref: function showAllHref() {
      return this.attrs.path + "/notifications";
    },
    hasUnread: function hasUnread() {
      return this.getItems().filterBy("read", false).length > 0;
    },
    _findStaleItemsInStore: function _findStaleItemsInStore() {
      return this.store.findStale("notification", {
        recent: true,
        silent: this.currentUser.enforcedSecondFactor,
        limit: this.estimateItemLimit()
      }, { cacheKey: "recent-notifications" });
    }
  });
});

```

---

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年五月2日 18:43 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/9 "2020-05-02T18:43:37Z")

</div>

刚注意到，这个问题仅在我以管理员用户登录且同时显示 mini\_profiler 时出现。我使用普通用户登录后，功能正常。

---

<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: [2020年五月3日 01:28 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/10 "2020-05-03T01:28:58Z")

</div>

> [@Raj\_Rathore](#):
>
> DOMException：配额超出。

参见：

> <https://github.com/puppeteer/puppeteer/issues/1596#issuecomment-351874481>
>
> I seem to be hitting a limit when putting new entries into an IndexedDB within a… service worker in puppeteer: the error returned is "Quota exceeded". The db is really quite small though, and I've not seen this outside of puppeteer. Is there any way to increase or remove the quota?

或许可以清除所有本地存储。

---

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年五月3日 01:56 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/11 "2020-05-03T01:56:28Z")

</div>

我已经清除了存储空间，现在不再显示配额错误。但是，它仍在发起多次请求，导致我收到 429 响应，提示需要降低速度。我现在已不再使用 Cloudflare（_是否也应该在 app.yml 中注释掉 Cloudflare 模板？_）。错误在 `dasherize` 处依然相同。这些错误仅出现在管理员用户身上，并且我会很快被限流。

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2020年五月3日 06:27 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/12 "2020-05-03T06:27:39Z")

</div>

您正在运行哪些非官方插件和主题？有可能是其中一个产生了大量请求负载。

---

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年五月3日 09:09 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/13 "2020-05-03T09:09:36Z")

</div>

我正在使用以下插件

 ![Screenshot 2020-05-03 at 12.20.32 PM](https://global.discourse-cdn.com/meta/original/3X/2/a/2a7a69a48cede2ed1799299975ee30e005225619.png)

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [2020年五月3日 14:04 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/14 "2020-05-03T14:04:40Z")

</div>

作为入门建议，我会注释掉所有未使用的插件。即使已安装但被禁用，它们仍会给系统带来负担。

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2020年五月3日 21:43 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/15 "2020-05-03T21:43:35Z")

</div>

首先禁用所有第三方插件（即没有绿色对勾的插件）。这很可能就是问题所在。

---

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年五月4日 07:34 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/16 "2020-05-04T07:34:50Z")

</div>

我已经移除了 Cloudflare，并卸载了许多插件和第三方插件，但问题仍未解决。

 ![Screenshot 2020-05-04 at 1.00.37 PM](https://global.discourse-cdn.com/meta/original/3X/7/6/76265eaaab6d5128eafa64aebbe97a7e9f5f1199.png)

---

<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: [2020年五月4日 08:05 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/17 "2020-05-04T08:05:51Z")

</div>

> [@Raj\_Rathore](#):
>
> 移除了许多插件和第三方插件，

移除所有没有绿色对勾的项目并重新构建。

请在另一台计算机上确认是否出现相同的故障，可能是磁盘空间不足或存在其他本地问题。

---

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年五月4日 10:35 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/18 "2020-05-04T10:35:29Z")

</div>

在我的移动浏览器上它能正常工作：slight\_smile: 我会查一下，看看本地出了什么问题。可能是磁盘空间不足或磁盘驱动器速度慢导致的。不管怎样，能卸载掉几个不必要的插件真是太好了：laughing:

---

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年五月8日 07:49 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/19 "2020-05-08T07:49:12Z")

</div>

看来我仍然面临一些用户遇到的这个问题。

我认为我的问题与下面提到的问题有关，而且我在升级到该版本后遇到了此问题：

> [@User notifications "all" is empty, but responses, likes, etc have items](https://meta.discourse.org/t/user-notifications-all-is-empty-but-responses-likes-etc-have-items/140351):
>
> I got a report that a user’s notifications would load when clicking on the avatar. (It’s a recent upgrade running 2.4.0.beta10). There is a single non-standard plugin, but it doesn’t seem likely to be the cause and the issue is affecting only one user (at least that we know of). (And then I did an upgrade without my plugin and that didn’t fix it.) safe-mode didn’t help. When going to /u/username/notifications for one particular user no notifications are shown, but clicking on “responses”, “like…

我无法确定是什么导致了这个问题。它对新用户有效，但对其他用户却无效。我之前使用了一个 Discourse 关注插件，后来将其注释掉了，现在出现了这个问题。这是否可能是因为移除了该插件导致的？我猜测这可能只影响那些之前有关注者或使用过该插件的用户。这确实是一个大胆的假设。这个插件真的可能是罪魁祸首吗？

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2020年五月8日 19:20 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/20 "2020-05-08T19:20:19Z")

</div>

> [@Raj\_Rathore](#):
>
> 有没有可能我遇到这个问题是因为我卸载了那个插件？因为我推测这可能只发生在那些之前有粉丝或使用了该插件的用户身上？这其实是个大胆的猜测。这个插件真的可能导致这个问题吗？

是的，这是有可能的。由于我们并不拥有该插件，因此无法确定是否属实。您可以尝试重新启用该插件并进行检查。如果问题得到解决，请在该插件的主题帖中报告此问题。

---

<div class="post-metadata">

### Author: ![Raj\_Rathore](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raj_rathore/32/155320_2.png) [@Raj\_Rathore](https://meta.discourse.org/u/Raj_Rathore)
#### Post date: [2020年五月10日 19:16 UTC](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711/21 "2020-05-10T19:16:26Z")

</div>

@Falco 是的，这确实解决了这个问题。我已重新添加了 discourse-follow 插件，问题已解决。谢谢 🙂

[下一頁](https://meta.discourse.org/t/cloudflare-or-plugins-breaking-my-discourse-instance/149711.md?page=2)
