# Discourse-eventsがトピック削除時に500エラーを引き起こす場合がある（開発環境）: Calendar::Extractorが未初期化

**URL:** https://meta.discourse.org/t/discourse-events-can-cause-500-when-deleting-a-topic-in-development-uninitialized-calendar-extractor/411731
**Category:** Bug
**Tags:** dev-install, events
**Created:** [2026 年 9 月 6 日午前 1:16 UTC](https://meta.discourse.org/t/discourse-events-can-cause-500-when-deleting-a-topic-in-development-uninitialized-calendar-extractor/411731 "2026-09-06T01:16:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)
#### Post date: [2026 年 9 月 6 日午前 1:16 UTC](https://meta.discourse.org/t/discourse-events-can-cause-500-when-deleting-a-topic-in-development-uninitialized-calendar-extractor/411731/1 "2026-09-06T01:16:12Z")

</div>

ローカル開発インスタンスで無関係なトピック削除の変更をテストしていたところ、トピックの削除時に **500 Internal Server Error** が返されました。

エラーが発生した開発インスタンスは、以下の Discourse コミットを正確に実行していました:

> <https://github.com/Ethsim12/discourse/commit/58070a6173a7ba162dbc8ec1165836043290d5ab>

 ![image](https://global.discourse-cdn.com/meta/original/4X/b/3/0/b30281dca989bd06e6b37d629b80b5ff70dcc483.jpeg)

リクエストは以下の通りでした:

```plaintext
DELETE /t/35

```

例外は `discourse-events` の `:post_destroyed` コールバックから発生しています:

```plaintext
NameError (uninitialized constant DiscourseEvents::Calendar::Extractor)

plugins/discourse-events/plugin.rb:639:in 'block (2 levels) in Plugin::Instance#activate!'
lib/plugin/instance.rb:676:in 'block in Plugin::Instance#on'
lib/discourse_event.rb:13:in 'block in DiscourseEvent.trigger'
lib/discourse_event.rb:12:in 'DiscourseEvent.trigger'
lib/post_destroyer.rb:91:in 'PostDestroyer#destroy'
app/controllers/topics_controller.rb:818:in 'TopicsController#destroy'

```

関連するコールバックは、以下の呼び出しを試みているようです:

```ruby
DiscourseEvents::Calendar::Extractor.destroy(post)

```

完全なエラーページには以下が報告されています:

```plaintext
NameError (uninitialized constant DiscourseEvents::Calendar::Extractor)

```

`PostDestroyer#destroy` は `:post_destroyed` をトリガーする地点にすでに到達しているため、コールバックが例外をスローする前に削除が適用されている可能性があります。その結果、ブラウザは 500 エラーを受信します。

これは開発環境で発生しました。`DiscourseEvents::Calendar::Extractor` は通常 #events によって提供されるため、実装自体が欠落しているのではなく、開発モードの再読み込みやプラグインの状態に関連しているのではないかと考えています。

当時、私は無関係なトピック削除のコードに取り組んでいましたが、例外自体は完全に `discourse-events` の `:post_destroyed` ハンドラー内部で発生しています。

開発インスタンスで `DiscourseEvents::Calendar::Extractor` が未定義になるという現象に遭遇された方はいますか？これは開発環境の再読み込みやプラグインの状態に関連している可能性がありますか？それとも、`:post_destroyed` コールバックはエクストラクターを異なる方法でロードすべきでしょうか？

---

<div class="post-metadata">

### Author: ![kris.kotlarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kris.kotlarek/32/176919_2.png) [@kris.kotlarek](https://meta.discourse.org/u/kris.kotlarek)
#### Post date: [2026 年 9 月 8 日午前 4:24 UTC](https://meta.discourse.org/t/discourse-events-can-cause-500-when-deleting-a-topic-in-development-uninitialized-calendar-extractor/411731/4 "2026-09-08T04:24:37Z")

</div>

この問題を報告してくださりありがとうございます。ローカル環境で再現を確認しました。良いニュースとしては、これはコードのリロードがトリガーされた開発環境でのみ発生するはずです。

開発時の読み込みを修正するPRを作成しました：

[https://github.com/discourse/discourse/pull/43359](https://github.com/discourse/discourse/pull/43359)

---

<div class="post-metadata">

### Author: ![kris.kotlarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kris.kotlarek/32/176919_2.png) [@kris.kotlarek](https://meta.discourse.org/u/kris.kotlarek)
#### Post date: [2026 年 9 月 9 日午後 10:00 UTC](https://meta.discourse.org/t/discourse-events-can-cause-500-when-deleting-a-topic-in-development-uninitialized-calendar-extractor/411731/5 "2026-09-09T22:00:52Z")

</div>

このトピックは15時間後に自動的にクローズされました。これ以上返信することはできません。
