state_machines-activerecord icon indicating copy to clipboard operation
state_machines-activerecord copied to clipboard

Is it possible to configure `after_transition` to occur after the `after_commit` callback?

Open joelzwarrington opened this issue 11 months ago • 0 comments

It would be nice to be able to perform the after_transition callback after the after_commit callback.

There's an issue where if your after_transition starts a job, the model is retrieved via GlobalID and if your job is ran quickly, the model may not have been saved yet, thus leading to a race condition.

https://github.com/state-machines/state_machines-activerecord/blob/8b5ee569b9a041bdafcbad5c646ee501a8c3bd83/lib/state_machines/integrations/active_record.rb#L305

joelzwarrington avatar Mar 14 '24 19:03 joelzwarrington