I have a process in which I am generating pdf files and saving in temporary directory .The temporary directory lies in source code repository.
when I am retrieving files by hitting API end point , it returns no files present sometimes and sometimes it gives me files which are present . we having this issue in production where we are using pm2 to create node instance to run the code.
I believe each time request comes , it passes to instance and if instance having files in their temporary directory , it return.
Problem -- will Each instance have different local temporary directory or Each instance will share common directory .
In POSIX based systems (Linux, Windows and MacOS) pm2 creates a separate process for each instance of your node application. Because they are separate processed they will have separate memory regions and separate temporary file locations.
In order to fix your issue you will need to find a common location where all of your node instances (aka. processes) can read and write the PDF files, making sure that no two process overwrite each others files.