In Photoshop CC 19, there is a critical ExtendScript bug. The crux of the issue is this: regardless of the Document instance on which you invoke the saveAs() method, the data written out will ALWAYS be that of the active (frontmost) document in Photoshop. This can easily result in data loss if the saveAs operation is being performed on a document instance that is not the frontmost (as its file will be replaced with the data from the active tab).
Steps to reproduce:
1. Open two documents - I used JPGs for testing (let's call them "Image1.jpg" and "Image2.jpg")
2. Make sure "Image 2" is the active (frontmost) document in Photoshop.
3. Using the ExtendScript toolkit, connect to Photoshop CC 19