Callback in Node red

I have lot of flows in my node red project, i want to track each and every flow, after success of each flow i want do some action like store data in db flow1 successfully injected , how can track each and every flow?

Right now you have to explicitly create the flows to do what you want. The node-red runtime has no concept of a flow being 'successful' - so there's nothing to hook into for what you want.

In the future, we will have a new node api that will allow nodes to tell the runtime they have finished with success. That will come with a new 'Complete' node that can be used to trigger (much like the Status/Catch nodes). However, even once we release the new api, it will take some time to be adopted - there are 1700+ nodes out there, many of which are not actively maintained.

1 Like

You could store a status value in a global context and present each state on a dashboard.https://nodered.org/docs/user-guide/context

@knolleary how can i log my flow, i mean each node executed or not with timings start time and end time

Enable the metrics log level in settings.js.

You may want to create a custom logger to handle just the metrics events rather than flood your main log. The docs have some details.

Whether that gives you what you want, you'll have to try and see.

@knolleary how can i put in all logs in file like access.log, error.log files

There is only a single, unified log in Node-RED, it isn't like a web server in the traditional sense.

If you have a separate reverse proxy in front of the Node-RED service and want those logs and Node-RED's all in one place, you will need some kind of log aggregation service.

1 Like

@knolleary after depoy node ...if i want to close my current browser tab then how should i do that in node red???

i tried with window.close() but it is giving some error...can you please suggest me the solution?

@dhpatel177 this thread is 2 years old and unrelated to your question. Please do not post to random old threads - start a new thread.

You cannot programmatically close a browser window, unless that window was originally opened with a Window.open call - see https://developer.mozilla.org/en-US/docs/Web/API/Window/close for more information. I have nothing to add. If you want to follow up , start a new thread. But to be clear, the answer to your question is : you cannot do that.