1

I have an application built with an Electron (node) "backend" and an Angular front end. The real world problem we are trying to build for is a long term (days at a time) monitoring solution. There is a 3rd party instrument that will generate files every few seconds.

The Electron process watches for these input files and puts them in a queue (array), it will also send this file to the frontend Angular process where it is displayed to the user.

There are two intervals in the Electron process. One that checks the queue every few seconds and will run a process on them to create an output file. This output file is also then sent to the frontend to be displayed. The second one will periodically delete the oldest input and output files to conserve disk space, because remember, we are running this process for potentially days at a time and the files are not small.

On the frontend side, there are also listeners and timers. When the frontend receives an input or output file, it places it in a corresponding queue. And similarly, it has intervals to periodically check the queues and display the next input and output file.

The issue we are having, is that sometimes the timers get out of sync, and the frontend tries to display a file that has already been removed.

My question is, is there a better way to handle these incoming files so we don't delete anything that hasn't been viewed yet?

I'm not married to keeping the timers/intervals, but one reason we have them is without them, the frontend might receive several files in rapid succession and they would then be shown for a split second before moving on to the next one. The timers give each file some breathing room.

0 Answers0