From f2ea1d5b4ee6d0bd8861fa7923792e4c64e649dc Mon Sep 17 00:00:00 2001 From: Adviti Mishra Date: Thu, 18 Jul 2024 16:21:39 -0400 Subject: [PATCH] raising an invalid around callback error earlier on as soon as a fiber is detected to be dead --- lib/mongoid/interceptable.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mongoid/interceptable.rb b/lib/mongoid/interceptable.rb index b888fbb3ee..3e946740be 100644 --- a/lib/mongoid/interceptable.rb +++ b/lib/mongoid/interceptable.rb @@ -181,14 +181,14 @@ def _mongoid_run_child_callbacks_with_around(kind, children: nil, &block) end end - fibers.each(&:resume) + fibers.each do |fiber| + fiber.resume + raise Mongoid::Errors::InvalidAroundCallback unless fiber.alive? + end block&.call fibers.reverse.each(&:resume) - - rescue FiberError - raise Mongoid::Errors::InvalidAroundCallback end # Execute the callbacks of given kind for embedded documents without