Anybody know what this MiniRacer::RuntimeError (TypeError: moment.tz is not a function) error is?

I’ve been getting this error frequently now and it’s beginning to become a large annoyance. Running ./launcher restart app temporarily resolves the issue, but after a bit it will return.

I get this error when I edit posts especially, I’ve had a history in the past where if a Date/Time stamp is inserted such as this → 2024-11-11T05:00:00Z, then it would result in the error.

Can someone please examine this error and figure out where the source is, or if anyone has encountered this before know a better workaround? Thanks.

MiniRacer::RuntimeError (TypeError: moment.tz is not a function) lib/pretty_text.rb:239:in `block in markdown' lib/pretty_text.rb:686:in `block in protect' lib/pretty_text.rb:686:in `synchronize' lib/
mini_racer (0.14.1) lib/mini_racer.rb:237:in `eval_unsafe'
mini_racer (0.14.1) lib/mini_racer.rb:237:in `block (2 levels) in eval'
mini_racer (0.14.1) lib/mini_racer.rb:378:in `timeout'
mini_racer (0.14.1) lib/mini_racer.rb:236:in `block in eval'
mini_racer (0.14.1) lib/mini_racer.rb:234:in `synchronize'
mini_racer (0.14.1) lib/mini_racer.rb:234:in `eval'
lib/pretty_text.rb:239:in `block in markdown'
lib/pretty_text.rb:686:in `block in protect'
lib/pretty_text.rb:686:in `synchronize'
lib/pretty_text.rb:686:in `protect'
lib/pretty_text.rb:176:in `markdown'
lib/pretty_text.rb:302:in `cook'
plugins/automation/lib/discourse_automation/scripts/append_last_checked_by.rb:31:in `block (2 levels) in <main>'
plugins/automation/app/models/discourse_automation/automation.rb:146:in `trigger!'
plugins/automation/lib/discourse_automation/event_handlers.rb:296:in `block in handle_after_post_cook'
activerecord (7.1.5) lib/active_record/relation/batches.rb:82:in `each'
activerecord (7.1.5) lib/active_record/relation/batches.rb:82:in `block in find_each'
activerecord (7.1.5) lib/active_record/relation/batches.rb:158:in `block in find_in_batches'
activerecord (7.1.5) lib/active_record/relation/batches.rb:396:in `block in batch_on_unloaded_relation'
<internal:kernel>:187:in `loop'
activerecord (7.1.5) lib/active_record/relation/batches.rb:372:in `batch_on_unloaded_relation'
activerecord (7.1.5) lib/active_record/relation/batches.rb:269:in `in_batches'
activerecord (7.1.5) lib/active_record/relation/batches.rb:157:in `find_in_batches'
activerecord (7.1.5) lib/active_record/relation/batches.rb:81:in `find_each'
plugins/automation/lib/discourse_automation/event_handlers.rb:271:in `handle_after_post_cook'
plugins/automation/plugin.rb:213:in `block (2 levels) in activate!'
lib/plugin/filter_manager.rb:17:in `block in apply'
lib/plugin/filter_manager.rb:17:in `each'
lib/plugin/filter_manager.rb:17:in `apply'
lib/plugin/filter.rb:15:in `apply'
app/models/post.rb:350:in `cook'
app/models/post.rb:871:in `block in <class:Post>'
activesupport (7.1.5) lib/active_support/callbacks.rb:448:in `instance_exec'
activesupport (7.1.5) lib/active_support/callbacks.rb:448:in `block in make_lambda'
activesupport (7.1.5) lib/active_support/callbacks.rb:202:in `block (2 levels) in halting'
activesupport (7.1.5) lib/active_support/callbacks.rb:707:in `block (2 levels) in default_terminator'
activesupport (7.1.5) lib/active_support/callbacks.rb:706:in `catch'
activesupport (7.1.5) lib/active_support/callbacks.rb:706:in `block in default_terminator'
activesupport (7.1.5) lib/active_support/callbacks.rb:203:in `block in halting'
activesupport (7.1.5) lib/active_support/callbacks.rb:598:in `block in invoke_before'
activesupport (7.1.5) lib/active_support/callbacks.rb:598:in `each'
activesupport (7.1.5) lib/active_support/callbacks.rb:598:in `invoke_before'
activesupport (7.1.5) lib/active_support/callbacks.rb:119:in `block in run_callbacks'
activesupport (7.1.5) lib/active_support/callbacks.rb:141:in `run_callbacks'
activesupport (7.1.5) lib/active_support/callbacks.rb:952:in `_run_save_callbacks'
activerecord (7.1.5) lib/active_record/callbacks.rb:441:in `create_or_update'
activerecord (7.1.5) lib/active_record/timestamp.rb:127:in `create_or_update'
activerecord (7.1.5) lib/active_record/persistence.rb:718:in `save'
activerecord (7.1.5) lib/active_record/validations.rb:49:in `save'
activerecord (7.1.5) lib/active_record/transactions.rb:309:in `block in save'
activerecord (7.1.5) lib/active_record/transactions.rb:365:in `block in with_transaction_returning_status'
activerecord (7.1.5) lib/active_record/connection_adapters/abstract/database_statements.rb:342:in `transaction'
activerecord (7.1.5) lib/active_record/transactions.rb:361:in `with_transaction_returning_status'
activerecord (7.1.5) lib/active_record/transactions.rb:309:in `save'
activerecord (7.1.5) lib/active_record/suppressor.rb:52:in `save'
lib/post_revisor.rb:499:in `update_post'
lib/post_revisor.rb:460:in `revise'
lib/post_revisor.rb:454:in `revise_and_create_new_version'
lib/post_revisor.rb:357:in `revise_post'
lib/post_revisor.rb:279:in `block in revise!'
activerecord (7.1.5) lib/active_record/connection_adapters/abstract/transaction.rb:535:in `block in within_new_transaction'
activesupport (7.1.5) lib/active_support/concurrency/null_lock.rb:9:in `synchronize'
activerecord (7.1.5) lib/active_record/connection_adapters/abstract/transaction.rb:532:in `within_new_transaction'
activerecord (7.1.5) lib/active_record/connection_adapters/abstract/database_statements.rb:344:in `transaction'
activerecord (7.1.5) lib/active_record/transactions.rb:212:in `transaction'
lib/post_revisor.rb:278:in `revise!'
app/controllers/posts_controller.rb:273:in `update'
actionpack (7.1.5) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (7.1.5) lib/abstract_controller/base.rb:224:in `process_action'
actionpack (7.1.5) lib/action_controller/metal/rendering.rb:165:in `process_action'
actionpack (7.1.5) lib/abstract_controller/callbacks.rb:259:in `block in process_action'
activesupport (7.1.5) lib/active_support/callbacks.rb:121:in `block in run_callbacks'
app/controllers/application_controller.rb:424:in `block in with_resolved_locale'
i18n (1.14.6) lib/i18n.rb:353:in `with_locale'
app/controllers/application_controller.rb:424:in `with_resolved_locale'
activesupport (7.1.5) lib/active_support/callbacks.rb:130:in `block in run_callbacks'
activesupport (7.1.5) lib/active_support/callbacks.rb:141:in `run_callbacks'
actionpack (7.1.5) lib/abstract_controller/callbacks.rb:258:in `process_action'
actionpack (7.1.5) lib/action_controller/metal/rescue.rb:25:in `process_action'
actionpack (7.1.5) lib/action_controller/metal/instrumentation.rb:74:in `block in process_action'
activesupport (7.1.5) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.1.5) lib/active_support/notifications/instrumenter.rb:58:in `instrument'
activesupport (7.1.5) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.1.5) lib/action_controller/metal/instrumentation.rb:73:in `process_action'
actionpack (7.1.5) lib/action_controller/metal/params_wrapper.rb:261:in `process_action'
activerecord (7.1.5) lib/active_record/railties/controller_runtime.rb:32:in `process_action'
actionpack (7.1.5) lib/abstract_controller/base.rb:160:in `process'
actionview (7.1.5) lib/action_view/rendering.rb:40:in `process'
rack-mini-profiler (3.3.1) lib/mini_profiler/profiling_methods.rb:115:in `block in profile_method' 
actionpack (7.1.5) lib/action_controller/metal.rb:227:in `dispatch'
actionpack (7.1.5) lib/action_controller/metal.rb:309:in `dispatch'
actionpack (7.1.5) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.1.5) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.1.5) lib/action_dispatch/journey/router.rb:51:in `block in serve'
actionpack (7.1.5) lib/action_dispatch/journey/router.rb:131:in `block in find_routes'
actionpack (7.1.5) lib/action_dispatch/journey/router.rb:124:in `each'
actionpack (7.1.5) lib/action_dispatch/journey/router.rb:124:in `find_routes'
actionpack (7.1.5) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.1.5) lib/action_dispatch/routing/route_set.rb:882:in `call'
lib/middleware/omniauth_bypass_middleware.rb:64:in `call'
rack (2.2.10) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.10) lib/rack/conditional_get.rb:40:in `call'
rack (2.2.10) lib/rack/head.rb:12:in `call'
actionpack (7.1.5) lib/action_dispatch/http/permissions_policy.rb:36:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:399:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
rack (2.2.10) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.10) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (7.1.5) lib/action_dispatch/middleware/c

I am getting an Internal Server Error for the Time/Date Insert. This has happened before, I am not sure what I did to fix, probably just a server restart - but I thought maybe its a good idea to make a topic about it since my last issue was resolved by speaking up about it. Error Details from logs:

Message

MiniRacer::RuntimeError (TypeError: moment.tz is not a function)
lib/pretty_text.rb:237:in `eval'
lib/pretty_text.rb:237:in `block in markdown'
lib/pretty_text.rb:677:in `block in protect'
lib/pretty_text.rb:677:in `synchronize'
lib/pretty_text.rb:677:in `protect'
lib/pretty_text.rb:174:in `markdown'
lib/pretty_text.rb:300:in `cook'
app/models/post_analyzer.rb:30:in `cook'
app/models/post_analyzer.rb:149:in `cooked_stripped'
app/models/post_analyzer.rb:126:in `raw_links'
app/models/post_analyzer.rb:143:in `link_count'
app/models/post.rb:312:in `public_send'
app/models/post.rb:312:in `block (2 levels) in <class:Post>'
lib/validators/post_validator.rb:141:in `max_links_validator'
lib/validators/post_validator.rb:20:in `validate'
lib/post_creator.rb:179:in `valid?'
lib/post_creator.rb:187:in `create'
lib/new_post_manager.rb:321:in `perform_create_post'
lib/new_post_manager.rb:255:in `perform'
app/controllers/posts_controller.rb:223:in `create'
app/controllers/application_controller.rb:428:in `block in with_resolved_locale'
app/controllers/application_controller.rb:428:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:35:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:415:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
lib/middleware/default_headers.rb:13:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/processing_request.rb:12:in `call'
lib/middleware/request_tracker.rb:410:in `call'

Backtrace

lib/pretty_text.rb:237:in `eval'
lib/pretty_text.rb:237:in `block in markdown'
lib/pretty_text.rb:677:in `block in protect'
lib/pretty_text.rb:677:in `synchronize'
lib/pretty_text.rb:677:in `protect'
lib/pretty_text.rb:174:in `markdown'
lib/pretty_text.rb:300:in `cook'
app/models/post_analyzer.rb:30:in `cook'
app/models/post_analyzer.rb:149:in `cooked_stripped'
app/models/post_analyzer.rb:126:in `raw_links'
app/models/post_analyzer.rb:143:in `link_count'
app/models/post.rb:312:in `public_send'
app/models/post.rb:312:in `block (2 levels) in <class:Post>'
lib/validators/post_validator.rb:141:in `max_links_validator'
lib/validators/post_validator.rb:20:in `validate'
lib/post_creator.rb:179:in `valid?'
lib/post_creator.rb:187:in `create'
lib/new_post_manager.rb:321:in `perform_create_post'
lib/new_post_manager.rb:255:in `perform'
app/controllers/posts_controller.rb:223:in `create'
actionpack (8.0.2) lib/action_controller/metal/basic_implicit_render.rb:8:in `send_action'
actionpack (8.0.2) lib/abstract_controller/base.rb:226:in `process_action'
actionpack (8.0.2) lib/action_controller/metal/rendering.rb:193:in `process_action'
actionpack (8.0.2) lib/abstract_controller/callbacks.rb:261:in `block in process_action'
activesupport (8.0.2) lib/active_support/callbacks.rb:120:in `block in run_callbacks'
app/controllers/application_controller.rb:428:in `block in with_resolved_locale'
i18n (1.14.7) lib/i18n.rb:353:in `with_locale'
app/controllers/application_controller.rb:428:in `with_resolved_locale'
activesupport (8.0.2) lib/active_support/callbacks.rb:129:in `block in run_callbacks'
activesupport (8.0.2) lib/active_support/callbacks.rb:140:in `run_callbacks'
actionpack (8.0.2) lib/abstract_controller/callbacks.rb:260:in `process_action'
actionpack (8.0.2) lib/action_controller/metal/rescue.rb:27:in `process_action'
actionpack (8.0.2) lib/action_controller/metal/instrumentation.rb:76:in `block in process_action'
activesupport (8.0.2) lib/active_support/notifications.rb:210:in `block in instrument'
activesupport (8.0.2) lib/active_support/notifications/instrumenter.rb:58:in `instrument'
activesupport (8.0.2) lib/active_support/notifications.rb:210:in `instrument'
actionpack (8.0.2) lib/action_controller/metal/instrumentation.rb:75:in `process_action'
actionpack (8.0.2) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (8.0.2) lib/active_record/railties/controller_runtime.rb:39:in `process_action'
actionpack (8.0.2) lib/abstract_controller/base.rb:163:in `process'
actionview (8.0.2) lib/action_view/rendering.rb:40:in `process'
rack-mini-profiler (4.0.1) lib/mini_profiler/profiling_methods.rb:116:in `block in profile_method'
actionpack (8.0.2) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (8.0.2) lib/action_controller/metal.rb:335:in `dispatch'
actionpack (8.0.2) lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
actionpack (8.0.2) lib/action_dispatch/routing/route_set.rb:50:in `serve'
actionpack (8.0.2) lib/action_dispatch/journey/router.rb:53:in `block in serve'
actionpack (8.0.2) lib/action_dispatch/journey/router.rb:133:in `block in find_routes'
actionpack (8.0.2) lib/action_dispatch/journey/router.rb:126:in `each'
actionpack (8.0.2) lib/action_dispatch/journey/router.rb:126:in `find_routes'
actionpack (8.0.2) lib/action_dispatch/journey/router.rb:34:in `serve'
actionpack (8.0.2) lib/action_dispatch/routing/route_set.rb:908:in `call'
lib/middleware/omniauth_bypass_middleware.rb:35:in `call'
rack (2.2.17) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.17) lib/rack/conditional_get.rb:40:in `call'
rack (2.2.17) lib/rack/head.rb:12:in `call'
actionpack (8.0.2) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:415:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
rack (2.2.17) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.17) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (8.0.2) lib/action_dispatch/middleware/cookies.rb:706:in `call'
actionpack (8.0.2) lib/action_dispatch/middleware/callbacks.rb:31:in `block in call'
activesupport (8.0.2) lib/active_support/callbacks.rb:100:in `run_callbacks'
actionpack (8.0.2) lib/action_dispatch/middleware/callbacks.rb:30:in `call'
actionpack (8.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:31:in `call'
actionpack (8.0.2) lib/action_dispatch/middleware/show_exceptions.rb:32:in `call'
logster (2.20.1) lib/logster/middleware/reporter.rb:40:in `call'
lib/middleware/default_headers.rb:13:in `call'
railties (8.0.2) lib/rails/rack/logger.rb:41:in `call_app'
railties (8.0.2) lib/rails/rack/logger.rb:29:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
actionpack (8.0.2) lib/action_dispatch/middleware/request_id.rb:34:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
rack (2.2.17) lib/rack/method_override.rb:24:in `call'
actionpack (8.0.2) lib/action_dispatch/middleware/executor.rb:16:in `call'
rack (2.2.17) lib/rack/sendfile.rb:110:in `call'
rack-mini-profiler (4.0.1) lib/mini_profiler.rb:334:in `call'
lib/middleware/processing_request.rb:12:in `call'
message_bus (4.4.1) lib/message_bus/rack/middleware.rb:60:in `call'
lib/middleware/request_tracker.rb:410:in `call'
actionpack (8.0.2) lib/action_dispatch/middleware/remote_ip.rb:96:in `call'
railties (8.0.2) lib/rails/engine.rb:535:in `call'
railties (8.0.2) lib/rails/railtie.rb:226:in `public_send'
railties (8.0.2) lib/rails/railtie.rb:226:in `method_missing'
rack (2.2.17) lib/rack/urlmap.rb:74:in `block in call'
rack (2.2.17) lib/rack/urlmap.rb:58:in `each'
rack (2.2.17) 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>'

Env

HTTP HOSTS: 

EDIT: Manually rebuilding resolved this, but since its happened before I am still curious on preventing again in the future.

1 Like

The issue has also been encountered here

While that is the same error (500), I do not think it’s the same situation(even though similar), since my issue happened after I updated Discourse, which should have updated core plugins as well.

The OP of that topic - said they updated a core plugin to fix - while I updated the entire platform - and it happened after an update.

Issue happened again today this time without any update being done prior to the error occurring. Still hoping for someone to respond with a solution.

can’t believe this is being ignored. I am still getting the ERROR - Chat GPT says its something to do with a missing Import :upside_down_face:

Can you provide step by step replication steps? How are you arriving at this error message?

Is your site self-hosted? If so, can you confirm you’ve recently done a rebuild from the command line and your site is up to date, and you are still able to replicate?

The issue happens when users are creating topics and inserting a timestamp. They insert the timestamp, and the error occurs when they press “Post” or “Edit” a post I believe. I personally cannot reproduce it. The information I provide is from the Error logging information, and what my moderators are reporting to me.

Yes, it is self-hosted and resolves on its own when I rebuild but the issue seems to always return. For the last week it’s been a daily return.

For context - I use Discourse for my small moderation team to log actions performed within our community - so we use the date/time insert every time we log something.

I have more of the details from the error log if you need them.

can you share the markdown here for a post that generates the internal server error message?

We use the button within the composer and not insert through a markdown format, so I am unsure what you are looking for.

For context, its hard to reproduce, but happens frequently. I have to update Discourse or rebuild to stop the error. I have narrowed it down to the Date/Time plugin as you can still post without it - which brought me to here.

Thanks!

I am trying to get replication steps. If you have a post with just the below markdown, what happens?

[date=2025-08-15 timezone="America/Los_Angeles"]

I will post that below and see if I can replicate your problem here. It appears I cannot. What does the markdown for your inserted time/date look like?

2025-08-15T07:00:00Z

Edit: I will post the markdown soon. I didn’t have the button pressed. :sweat_smile:

[date-range from=2025-08-06 to=2025-09-03 timezone="Europe/Warsaw"]

This is the stamp in the post (Where one of the instances of the error occurred).

Posting the markdown, you mention does not trigger the error for me - In Fact I have been unable to reproduce it at all myself.

Well, this explains methinks why nobody is jumping to help you fix your problem. Without replication steps, it’s very difficult to figure out what is going on and to determine if it is a bug.

I do see another topic from last November which quotes a similar error from the log and is about editing posts with timestamps in them. Are you able to replicate the error when editing a topic containing a timestamp, vs creating a new topic?

I’ll move this one into there.

Edit: I see you posted to Moment.js Dependency is causing Internal Server Errors - Users unable to post - Support - Pavilion about this too. If you are using plugins or theme components, once you are able to replicate this reliably you can disable them (or try safe mode) and see if that makes the problem go away. If so, then you need to take it up with the authors of the offending plugin/theme component.

1 Like

I will post here again when the issue happens - and hopefully will have a reproduction process by then.

It has been happening when my moderators create new posts, but I have seen them complain about it when Editing also. SO I have no idea. I am sorry I do not have more.

2 Likes