Let's assume there's a file temp.json at version 1.
At time 0 process 1 reads version 1
At time 1 process 2 reads version 1
At time 3 process 2 fs.writeFileSync to version 2
At time 3 process 1 fs.writeFileSync to version 3
How does nodejs operates over these two conflicting writes?
To add to this all I tried using fs.writeFile concurrently from two processes and the end result of temp.json was mix of content from two processes. Help me understand this as well