app.doScript causing memory corruption for download

Seems that app.doScript struggles with asynchronous operations. I have an issue with that too, when using the file system (see my Problem with Undo and File)