-
|
Hey, I'm currently working on workflows that I would like to be able to stop manually. To do this, I'm currently using sagas and an exception. The problem is that the workflow also contains timers, and if a cancellation signal is received while a timer is running, the exception is thrown twice. I just can't seem to solve this problem... I actually thought that awaitWithTimeout would solve the problem, but that doesn't help either. Has anyone here done something similar or perhaps have a tip for me? I've attached the code here in the files. There you'll find the workflow, the corresponding exception thrown, the cancellation activity, and the controller that sends the signal to the workflow. GetAdReportWorkflow.php |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
|
Okay, I've found a solution. I'm just not sure how clean it is. I'm not using a signal, but going through the cache instead. The webhook route sets a cache entry “workflow_$id_cancelled” with true and, for example, 600s ttl. In the workflow, I no longer check for $this->cancelled, but now check for this cache entry. The difference is that a signal causes the workflow to be immediately run again from the start with the new value for $this->cancelled, thus directly throwing the exception. By only entering a cache value, the workflow is not immediately read again, or rather, the workflow is not interfered with at all at first. Only when the cache is checked after a timer, for example, does it abort there. |
Beta Was this translation helpful? Give feedback.
-
|
I updated the docs based on this question: https://durable-workflow.com/docs/features/side-effects/#signals-and-control-flow |
Beta Was this translation helpful? Give feedback.
@Braindea7
Ah, I see the problem now.
You have to wrap the check in a
sideEffect.