Detect when flow editor is closed

Hi folks,

Is there any way (on the server side) to detect when a flow editor has client been closed?

For my new node-red-contrib-xterm node, a separate pseudo-terminal is started (on the server) for each flow editor that is started. I can easily trigger that from the client startup code. But as soon as a flow editor is closed, I need to stop the corresponding pseudo-terminal on the server.

But I cannot find a server-side event to accomplish this. Only found a client-side code snippet, and it doesn't work for me (e.g. when I close the tabsheet in Chrome where my flow is being displayed):"editor:close",function() { .... })

P.S. A side question: does anybody know whether there is (somewhere) a unique workspace id available, which I could use to unique identify the flow editors (to use as a key in the map where I store my pseudo-terminal instances)?

Thanks a lot!!

No, none of the features you are asking about are available.

Ah that is a pitty. Had hoped that the Node-RED core also had to do some cleanup somewhere if a client disconnects from the server. And that I could listen somehow to those events to do my stuff ...

So then I have to look for a workaround:

  • Had first thought to kill my pseudoterminal process automatically (when the user has no new command entered in the last x seconds) and spawn a new process when a new command is entered. However suppose a command is executed to tail a file, then I cannot simply interrupt that process just because the user is not entering new commands in the terminal.
  • So I assume my only option is that my client side should send a heartbeat (every x seconds) to keep the pseudo-terminal available.

If anybody has a better workaround or something that I should be aware of, please let me know!