oakes / odoyle-rules

A rules engine for Clojure(Script)
The Unlicense
530 stars 20 forks source link

remove-rule race condition? #28

Closed nivekuil closed 11 months ago

nivekuil commented 11 months ago

I'm running into an occasional exception where then_finally_fn is nil when it's invoked. All these rules are dynamic so I looked through the code and one thing jumps out to me. It looks like a node-id can be pushed to :then-finally-queue here https://github.com/oakes/odoyle-rules/blob/0925c3a8a1abd1e1fc29ad084d7c68e294c72c88/src/odoyle/rules.cljc#L386, then if the beta node is removed by remove-rule, when fire-rules makes it to here https://github.com/oakes/odoyle-rules/blob/0925c3a8a1abd1e1fc29ad084d7c68e294c72c88/src/odoyle/rules.cljc#L626, where (get beta-nodes node-id) is nil it will invoke a nil then-finally-fn. :then doesn't have this problem because of an additional layer of when-let.

oakes commented 11 months ago

You are absolutely right. Can you try the commit I just pushed? I made remove-rule update both queues and added a test that reproduces it.

nivekuil commented 11 months ago

it's been working, thanks!

oakes commented 11 months ago

Pushed 1.3.1 with the fix, thanks for reporting this.