Stopping workflow execution

Hi there,

Suppose we have this workflow:
Trigger => X node => Y node

I need to stop the workflow whenever it reaches to X node, one way is to run throw new Error in execute function in the X node. But I prefer more peaceful way to stop a execution.

What do you think about this?

Hey @jellybean!

If you don’t want to execute the Y node, you can either disconnect the node, or disable it. If you want to execute it based on a condition, you can add an IF node in between the X node and the Y node.

1 Like

Thanks @harshil1712
I know I can use the If node, But I don’t want to. Also I don’t want to disconnect it. Is there any “coding” way instead of throwing an error?

A Function-Node returning an empty array.

return [];

If there are no items then n8n will stop.


Wow great @jan Thank you very much.

You are welcome. Have fun!

1 Like

Hi @jellybean! Glad you found the solution.

Could you share with us why you want to do this? I’m intrigued…

Sure @sirdavidoff , I was trying to implement wait functionality. But I found the “wait functionality PR” and it’s wonderful, so I ignored my implementation and just used that PR.

Uh that branch is not even in Alpha state yet. Is only PoC implementation without any proper testing. So the chance is for that reason quite high that you will run into problems at some point. Also will the DB probably still change, meaning that if you then upgrade to the final version it is best to export all your workflows and credentials and then reimport them in the stable version. As also the Wait-Node will for sure also change, will the workflows break and you then have to fix them manually.

Just that you know what to expect :wink:

1 Like

@jan Thanks for the explanations.
Actually I didn’t pull the branch, I just copied the codes related to wait node line by line! Also I didn’t copy the SleepTracker file at all, I’m using different approach: A crone job running on server that check database (sleepTill column) every minute. It seems stable to me :slight_smile: