Hi.
In some conditions, instead of using multiple nested if-else steps, we use RESPONSE step to stop the execution of a SA.
But this does not work well in case of schedulers, since response step is not supported and it generates "this.res.status is not a function" exception.
Is there any way other to stop the execution of a server action? Like a BREAK statement works in for loop.
Or if there is something that can be configured using custom module, that would do too. The requirement is that it should work in schedulers.
Unfortunately, none of these are quite relevant.
To put my issue in another terms: I need a way to cleanly exit a server action, so that it does not generate any exception.
Its not relevant to a loop, but more in terms of exiting a scheduler.
Made a better mock for the response object that should work in the scheduler. The mock object catches the send/json methods and set the headersSent property on the object which is used to to skip action steps after the response has been sent.
Here the update, unzip to lib/setup: cron.zip (754 Bytes)
@patrick Was on a break, and have resumed work today.
We tested this an it works as expected - which solves the primary issue.
But for the sake of better UX, a separate step or renaming of “Response” to “Response and Exit” could be useful. Or maybe another way to inform the user on how the response step works.
Looks like you forgot to integrate code for "End" into production (windows)
{
status: "500",
message: "Action end doesn't exist in core",
stack: "Error: Action end doesn't exist in core
at App._exec (E:\webs\extensions\lib\core\app.js:698:17)
at App._exec (E:\webs\extensions\lib\core\app.js:675:20)
at App.exec (E:\webs\extensions\lib\core\app.js:644:16)
at App.define (E:\webs\extensions\lib\core\app.js:626:16)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
}
Have checked core.js and the end: function looks to be missing
The end step is almost the same as the response step, with response you can output your own custom status code and data while with end it will just output the current data from the executed steps.