Open shahidkhaliq opened 1 month ago
To be honest I'm not sure why this code runs like that.
However, it doesn't seem that your intention to postpone enqueue from callbacks would work at all, as ActiveJob callbacks are built with plain ActiveSupport callbacks and you need to halt callback chain by throwing :abort
, see: https://api.rubyonrails.org/classes/ActiveSupport/Callbacks.html#method-i-run_callbacks
Anyway, I would recommend implementing this in some other way, e.g. by redefining the whole enqueue
method of ActiveJob job.
Also see https://github.com/Envek/after_commit_everywhere/issues/27#issuecomment-1692865436
Hello, thanks for all the hard work on this gem! I've been trying to use this gem to prevent ActiveJob jobs from enqueueing within transactions but have run into some unexpected behavior. If my job looks like the following:
And I try to enqueue it from within a transaction:
It outputs
123 1234
instead of1234
that I'm expecting. It seems like all the callbacks preceding the callback that hasafter_commit
are run twice instead of once.This is on
Rails 6.0.6.1
withafter_commit_everywhere (1.1.0)
.Am I doing something wrong here or is this a bug in the gem?