Scripted iterative document open/close fails to close files
Note: my sample code is jsx, but the problem may not be limited to jsx.
We have multiple products that sometimes show a problem with document.close() not actually closing the file, leading to incorrect functioning, memory bloat, slowdowns, and we believe some crashes. I provide a test script that takes a currently open document and iteratively copies it, opens the copy, then closes the copy -- after the loop is finished, the copy files are removed.
Important: If run from the ESTK or Scripts Panel, the script works as expected -- no problems. If run from a custom menu (setup script also provided), the problem happens every time.
We believe we've seen this in cases where a custom menu is not the launch mechanism, and may be intermittent in those cases.
We believe we've seen this in InDesign Server as well. My scripts have been tested in CC 2019 and CC 2020 and on both Win and Mac.
In order to run the "Test_menu.jsx" script for using a custom menu, the "Documents left open on close.jsx" script must be in a "TestScripts" folder in your 'home' or 'user' folder (i.e., inside of "~/TestScripts").
This problem is a real headache and is difficult to work around. It affects multiple product areas; we urge prompt attention to this problem.
Thanks.