Closed VinceG closed 7 years ago
We had some issues using this package while converting multiple PDFs at the same time, we experienced some race conditions due to the fact that the temporary file generated uses the uuid v1 which is based off a timestamp.
interesting, uuid v1 should be completely safe when just using a single process, since it is based in the timestamp of the engine. does your application is running in multiple processes? are you using something like the nodejs cluster
module or something like that? so far the only issue that comes to my mind about the usage of uuid v1 is when you have an app with more than 1 process which are trying to generate and write files to the same temp folder. if you are in that situation the problem can be easily solved by specifying a different temp folder for each process in the app, with that you won't have any collisions.
however i agree that probably is better to use uuid v4 (in fact i'm using v4 in another module), probably it will be a good idea to do a benchmark and see if there is an impact in performance when switching to uuid v4 and generating a lot of pdf files.
@bjrmatos We do use a cluster, however, this happens also when simply running tasks in parallel. If you create a file that generates 100 PDFs and run those in parallel it'll have this race condition.
Specifying a temp folder per process is harder than just making sure the temporary file generated is unique by using a more unique approach for temporary file generation (or allowing us to specify it at the very least).
We switched to v4 internally and saw no difference in CPU usage and memory consumption, although we didn't monitor or benchmarked the process time it seemed to be processing the conversions at the same rate as v1.
Merged in #75
Released in 0.5.5
Hey,
We had some issues using this package while converting multiple PDFs at the same time, we experienced some race conditions due to the fact that the temporary file generated uses the uuid v1 which is based off a timestamp.
Note
Although we are able to move this file anywhere we want once it's generated this still remains an issue. since the way it's currently setup it overwrites the temporary file if they are both being run at the exact same time.
I've created a PR to address this by applying the following fixes:
Example of race conditions currently caused by using the uuid v1