使用安全模式排查主题和插件的问题

:bookmark: This guide explains how to use Discourse’s Safe Mode to troubleshoot issues with themes and plugins.

:person_raising_hand: Required user level: All users

Discourse offers a “JavaScript Safe Mode” that allows any user to isolate the root cause of JavaScript issues caused by plugins, themes, or theme components. This feature is particularly useful for troubleshooting problems on your Discourse site.

Accessing Safe Mode

To access Safe Mode, follow these steps:

  1. Open a new browser tab.

  2. Enter the following URL in the address bar, replacing [your-site-name](http://discourse.example.com) with your actual Discourse site domain:

    http://discourse.example.com/safe-mode
    

    For example, the Safe Mode URL for the Discourse demo site is:
    https://try.discourse.org/safe-mode

  3. Click the ‘Enter Safe Mode’ button:

Safe Mode options

When entering Safe Mode, you can select from the following options:

  • Disable all themes and theme components
  • Disable unofficial plugins
  • Disable all plugins

By default, all three options are selected. However, you can enter Safe Mode multiple times with different combinations to isolate the specific component causing issues on your site.

Using Safe Mode

  1. Select the desired options on the Safe Mode page.
  2. Click “Enter Safe Mode” to apply your selections.
  3. You will see a banner indicating that Safe Mode is enabled.
  4. Browse your site to check if the issue persists with the selected components disabled.

Exiting Safe Mode

To exit Safe Mode, simply close your browser tab.

Important notes

When sharing a Safe Mode link for your site, be aware that it needs to be opened in a new tab or added directly to the address bar; otherwise, it may not work correctly.

:warning: Safe Mode currently only disables the JavaScript portions of plugins. To disable the server-side portion of a plugin, you must rebuild your container with the plugin commented out.

Troubleshooting

If you cannot load the initial Safe Mode selection page, try visiting the following URL, which will skip the page and load Safe Mode directly:

https://discourse.example.com/?safe_mode=no_themes,no_plugins

For example: https://try.discourse.org/?safe_mode=no_themes,no_plugins

:information_source: On Discourse versions 2.9.0.beta8 and below, you need to use ?safe_mode=no_custom,no_plugins instead.

Last edited by @hugh 2024-07-30T05:32:08Z

Check documentPerform check on document:
73 个赞

对我来说,这些链接只有在新标签页或窗口中打开时才有效。第一个链接会导向 oops 页面,第二个链接会导向主页。但安全模式横幅没有出现。当你将链接发送给用户让他们尝试安全模式时,第二个链接可能会导致问题。如果他们只是点击链接,他们仍然会在没有安全模式的情况下使用该网站。

也许应该将此信息添加到 #how-to。

4 个赞

抓得好——这两个链接都坏了。第一个需要一个 ?,第二个需要一个逗号而不是 %2C

2 个赞

在哪里需要一个“?”?
您能分享一个链接作为示例吗?

1 个赞

哦,抱歉,看来我第一个说错了:内部导航失败了,但新窗口可以正常工作。
Discourse Meta

我第二个也说错了!Discourse Meta - Discourse 官方支持论坛 不能作为同页导航。

我的错:有些东西坏了,但不是 URL。

1 个赞

我想这是因为它试图就地打开它们。与其争论,我已将其替换为 try.discourse.org:slight_smile:

2 个赞

我认为管理员应该知道分享这些链接很容易出问题。

例如,我在 meta 上报告了一个问题。你可能会问:“你能试试 https://meta.discourse.org/safe-mode 吗?”然后我会告诉你链接不起作用。
或者更糟糕的是:你想指定我只禁用主题,所以你让我试试 https://meta.discourse.org/?safe_mode=no_themes。我的问题仍然存在。你怎么确定我真的使用了安全模式?作为一个用户,我认为它起作用了,因为当我点击链接时发生了一些事情。

在我在这里发帖后,你就知道了。但其他管理员怎么知道他们必须注意这可能是一个问题?

3 个赞

鉴于此安全主页会替换所有内容的性质,我想知道是否应破例在新标签页中打开此链接。

2 个赞

我添加了一个注释,还有一个“成功”的截图。看起来怎么样?

4 个赞

3 篇帖子已拆分为新主题:安全模式是否应默认关闭非员工用户?