DEV: Fix race condition when enqueuing edit wiki-ed notification.

DEV: Fix race condition when enqueuing edit wiki-ed notification.

diff --git a/app/services/post_action_notifier.rb b/app/services/post_action_notifier.rb
index 22077ea..237f7e5 100644
--- a/app/services/post_action_notifier.rb
+++ b/app/services/post_action_notifier.rb
@@ -115,10 +115,12 @@ class PostActionNotifier
     end
 
     if user_ids.present?
-      Jobs.enqueue(:notify_post_revision,
-        user_ids: user_ids,
-        post_revision_id: post_revision.id
-      )
+      DB.after_commit do
+        Jobs.enqueue(:notify_post_revision,
+          user_ids: user_ids,
+          post_revision_id: post_revision.id
+        )
+      end
     end
   end

GitHub sha: a36fe019

1 Like