Running npx novu@latest dev with Express executes all workflows on startup with empty payload
Hi - I'm new here and Novu is the solution we wanted for a long time at Cling Systems ππΈπͺ.
I followed the Express quickstart quide for @novu/framework. I run my express server on port 5003 and register my workflows like this:
Here are two dummy workflows I try to setup:
When I start the local novu studio like with command
npx novu@latest dev --port 5003
the both the workflows run. See attached image of logs where the logger output is displayed before the console output of discovered workflows.
Is this how it's intended to work? If so what is the recommended way to handle more complex workflows where we trigger different database queries and other service calls?
Any help appreciated π
2 Replies
Yes, this is the intedned behaviour, as a discover command builds the workflow structure. The discover phase however doesn't run the "step" handler functions. Running any code in your database needs to happen in a step handler, or if it's reused than in a custom step that returns the value. Doing any side effect actions not inside a step is not recommended
That makes sense Dima, thanks a lot π