发布时遇到500错误,moment.tz运行时错误

您好,我最近在 Discourse 论坛上发帖时遇到一个错误。我查看了错误日志,发现了这个,日期和时间与我反复尝试发帖的时间相符。我收到了一个 500 错误 用户消息。

此图片显示在终端或代码编辑器窗口中显示的错误消息,指示与库或模块无法正常工作相关的运行时错误。(由 AI 标注)

当我点击错误日志时,输出部分显示以下内容:

JavaScript at addLocalDate (discourse/plugins/discourse-local-dates/lib/discourse-markdown/discourse-local-dates:24:29)
JavaScript at Object.date [as onMatch] (discourse/plugins/discourse-local-dates/lib/discourse-markdown/discourse-local-dates:44:7)
JavaScript at TextPostProcessRuler.applyRule (discourse-markdown-it/features/text-post-process:56:30)
JavaScript at textPostProcess (discourse-markdown-it/features/text-post-process:109:13)
JavaScript at replacer (discourse-markdown-it/features/text-post-process:122:44)
JavaScript at Object.textReplace (pretty-text/text-replace:62:23)
JavaScript at Array.<anonymous> (discourse-markdown-it/features/text-post-process:123:85)
JavaScript at Core.process (<anonymous>:2606:15)
JavaScript at MarkdownIt.parse (<anonymous>:6887:15)
JavaScript at MarkdownIt.render (<anonymous>:6902:38)
mini_racer (0.9.0) lib/mini_racer.rb:228:in `eval_unsafe'
mini_racer (0.9.0) lib/mini_racer.rb:228:in `block (2 levels) in eval'
mini_racer (0.9.0) lib/mini_racer.rb:369:in `timeout'
mini_racer (0.9.0) lib/mini_racer.rb:227:in `block in eval'
mini_racer (0.9.0) lib/mini_racer.rb:225:in `synchronize'
mini_racer (0.9.0) lib/mini_racer.rb:225:in `eval'
lib/pretty_text.rb:235:in `block in markdown'
lib/pretty_text.rb:681:in `block in protect'
lib/pretty_text.rb:681:in `synchronize'
lib/pretty_text.rb:681:in `protect'
lib/pretty_text.rb:173:in `markdown'
lib/pretty_text.rb:298:in `cook'
plugins/poll/lib/poll.rb:327:in `extract'
plugins/poll/lib/polls_validator.rb:15:in `validate_polls'
plugins/poll/plugin.rb:95:in `block (2 levels) in activate!'
lib/new_post_manager.rb:239:in `block in perform'
lib/new_post_manager.rb:238:in `any?'
lib/new_post_manager.rb:238:in `perform'
app/controllers/posts_controller.rb:215:in `create'
actionpack (7.0.8.4) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (7.0.8.4) lib/abstract_controller/base.rb:215:in `process_action'
actionpack (7.0.8.4) lib/action_controller/metal/rendering.rb:165:in `process_action'
actionpack (7.0.8.4) lib/abstract_controller/callbacks.rb:234:in `block in process_action'
activesupport (7.0.8.4) lib/active_support/callbacks.rb:118:in `block in run_callbacks'
app/controllers/application_controller.rb:424:in `block in with_resolved_locale'
i18n (1.14.5) lib/i18n.rb:351:in `with_locale'
app/controllers/application_controller.rb:424:in `with_resolved_locale'
activesupport (7.0.8.4) lib/active_support/callbacks.rb:127:in `block in run_callbacks'
activesupport (7.0.8.4) lib/active_support/callbacks.rb:138:in `run_callbacks'
actionpack (7.0.8.4) lib/abstract_controller/callbacks.rb:233:in `process_action'
actionpack (7.0.8.4) lib/action_controller/metal/rescue.rb:23:in `process_action'
actionpack (7.0.8.4) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
activesupport (7.0.8.4) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.8.4) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.8.4) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.0.8.4) lib/action_controller/metal/instrumentation.rb:66:in `process_action'
actionpack (7.0.8.4) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (7.0.8.4) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (7.0.8.4) lib/abstract_controller/base.rb:151:in `process'
actionview (7.0.8.4) lib/action_view/rendering.rb:39:in `process'
rack-mini-profiler (3.3.1) lib/mini_profiler/profiling_methods.rb:115:in `block in profile_method'
actionpack (7.0.8.4) lib/action_controller/metal.rb:188:in `dispatch'
actionpack (7.0.8.4) lib/action_controller/metal.rb:251:in `dispatch'
actionpack (7.0.8.4) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.0.8.4) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.0.8.4) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.8.4) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.8.4) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.8.4) lib/action_dispatch/routing/route_set.rb:852:in `call'
lib/middleware/omniauth_bypass_middleware.rb:64:in `call'
rack (2.2.9) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.9) lib/rack/conditional_get.rb:40:in `call'
rack (2.2.9) lib/rack/head.rb:12:in `call'
actionpack (7.0.8.4) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:393:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
rack (2.2.9) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.9) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (7.0.8.4) lib/action_dispatch/middleware/cookies.rb:704:in `call'
actionpack (7.0.8.4) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (7.0.8.4) lib/active_support/callbacks.rb:99:in `run_callbacks'
actionpack (7.0.8.4) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (7.0.8.4) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
actionpack (7.0.8.4) lib/action_dispatch/middleware/show_exceptions.rb:29:in `call'
logster (2.19.1) lib/logster/middleware/reporter.rb:40:in `call'
railties (7.0.8.4) lib/rails/rack/logger.rb:40:in `call_app'
railties (7.0.8.4) lib/rails/rack/logger.rb:27:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
actionpack (7.0.8.4) lib/action_dispatch/middleware/request_id.rb:26:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
rack (2.2.9) lib/rack/method_override.rb:24:in `call'
actionpack (7.0.8.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
rack (2.2.9) lib/rack/sendfile.rb:110:in `call'
actionpack (7.0.8.4) lib/action_dispatch/middleware/host_authorization.rb:131:in `call'
rack-mini-profiler (3.3.1) lib/mini_profiler.rb:334:in `call'
message_bus (4.3.8) lib/message_bus/rack/middleware.rb:60:in `call'
lib/middleware/request_tracker.rb:360:in `call'
actionpack (7.0.8.4) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
railties (7.0.8.4) lib/rails/engine.rb:530:in `call'
railties (7.0.8.4) lib/rails/railtie.rb:226:in `public_send'
railties (7.0.8.4) lib/rails/railtie.rb:226:in `method_missing'
rack (2.2.9) lib/rack/urlmap.rb:74:in `block in call'
rack (2.2.9) lib/rack/urlmap.rb:58:in `each'
rack (2.2.9) lib/rack/urlmap.rb:58:in `call'
unicorn (6.1.0) lib/unicorn/http_server.rb:634:in `process_client'
unicorn (6.1.0) lib/unicorn/http_server.rb:739:in `worker_loop'
unicorn (6.1.0) lib/unicorn/http_server.rb:547:in `spawn_missing_workers'
unicorn (6.1.0) lib/unicorn/http_server.rb:143:in `start'
unicorn (6.1.0) bin/unicorn:128:in `<top (required)>'
vendor/bundle/ruby/3.3.0/bin/unicorn:25:in `load'
vendor/bundle/ruby/3.3.0/bin/unicorn:25:in `<main>'

有人知道这是什么意思吗?我该如何解决?谢谢。

我们在一个未更新的 discourse 站点上遇到了此问题。更新似乎暂时缓解了该问题,但我们会密切关注,以防它再次出现。

2 个赞

是的,这个错误很令人惊讶,您能告诉我您正在使用哪个版本的 Discourse 吗?

1 个赞

我们正在使用 version: latest-release
遇到此问题时,Discourse 版本为 https://github.com/discourse/discourse/commits/v3.3.0.beta2
更新到版本 https://github.com/discourse/discourse/commits/v3.3.0.beta3 后,我们没有再遇到此问题。

1 个赞

我的网站似乎是 3.3.0.beta4-dev 版本。我猜这个版本不适用于生产环境?我看到了 dev 后缀。

它应该在生产环境中使用。由 Discourse 托管的社区也会获得这些“dev”版本。
“dev”后缀仅表示这不是 3.3.0-beta4 的最终版本。

4 个赞

一旦 3.3.0-beta4 的最终版本发布,我一定会更新并重试。这似乎只发生在使用了特殊模板的特定帖子中,尽管我们以前没有遇到过任何问题。它只是由 \u003ckbd\u003e\u003c/kbd\u003e 按钮、[details="Summary"][/details] 和图片组成。没有实验性的东西,只是核心的 Discourse 功能。

1 个赞

我有一个更新,我设法找到了原因。如果我插入一个日期和时间,例如 [date=2024-07-23 timezone="America/New_York"]/[date=2024-07-23 timezone=“America/New_York”]`,它将返回 500 错误。

有人知道解决方法吗?谢谢。

您正在使用哪个版本的 Discourse?您知道提交哈希吗?您可以在论坛的源代码页面中找到它:

Screenshot 2024-07-24 at 09.11.04

/safe-mode 中也会发生这种情况吗?

1 个赞

您好,关于您的问题,版本是 3.3.0.beta5-dev。关于您的问题,安全模式方面,当我进入安全模式时,插入日期/时间的按钮会消失。我认为这与 Discourse Calendar (and Event) 插件有关。

趣闻 :discourse: - 插入日期功能是 Local Dates 插件的一部分,该插件随 Discourse 一起提供(以及其他一些插件,如 Discobot、Hide Details、Chat 等)。不幸的是,由于它是一个插件,safe mode no_plugins 会像其他可选安装的插件一样禁用它。:frowning:

有一个选项可以仅禁用非官方插件来进入安全模式,并禁用主题和主题组件,这或许值得一试?

3 个赞

尽管应用了这些设置,但仍然弹出相同的消息。


image

1 个赞

我相当确定这是你环境中的问题。你知道这个论坛上的其他人是否能做到,或者只有你一个人遇到这个错误吗?

另外,请尝试查看浏览器控制台中网络选项卡,以及直接查看控制台是否有任何错误。

1 个赞

我在论坛上问了另一个人,他们也说收到了一个“内部服务器错误”。

当我尝试发帖时,我在控制台中也收到了这个错误。

也许是相关的?

如果您在 date-range 中输入了错误的 areatimezone,可能会在 discourse-local-dates 中触发运行时错误:

date 在错误的 areatimezone 下可以工作:
[date=2024-07-25 time=14:05:00 timezone="Europe/Berlinx"]
2024-07-25T14:05:00Z

date-range 则不行:

[date-range from=2024-07-25T15:00:00 to=2024-07-25T17:00:00 timezone="Europe/Berlinx"]
2024-07-25T15:00:00Z2024-07-25T17:00:00Z

从这里开始,其他日期将无法解析:
[date=2024-07-25 time=14:05:00 timezone="Europe/Berlin"]
2024-07-25T12:05:00Z

1 个赞

此主题在上次回复后 30 天自动关闭。不再允许回复。