mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-01 07:11:26 +08:00
What is the problem? The review queue throws a JavaScript error when processing MessageBus updates: ``` MESSAGE BUS FAIL: callback /reviewable_action caused exception TypeError: Cannot read properties of undefined (reading 'includes') ``` The bug flow is: 1. `Reviewable::PerformResult#initialize` only sets `@remove_reviewable_ids` when `success?` is true, leaving it nil otherwise 2. `ReviewablePerformResultSerializer` serializes nil as JSON null 3. MessageBus publishes this to `/reviewable_action` channel 4. The JS `_updateStatus` callback in `ReviewableItem` receives data with `remove_reviewable_ids` as null/undefined 5. Calling `.includes()` on null throws TypeError What is the solution? Always initialize `@remove_reviewable_ids` as an array in `Reviewable::PerformResult#initialize` (empty for failures, containing the reviewable id for successes). Also add defensive optional chaining in the JS `ReviewableItem#_updateStatus` callback and update the truthy check in `ReviewableItem#_performResult` to verify array length since `[]` is truthy in JavaScript. |
||
|---|---|---|
| .. | ||
| actions.rb | ||
| collection.rb | ||
| conversation.rb | ||
| editable_fields.rb | ||
| perform_result.rb | ||