With these changes, looped tests for 6 hours did not cause any errors. The only difference is in the way of listening for the end of the spawned process. onClose waits for the bound stdio to end. onExit does not wait for the stdio to close. Perhaps in some unspecified cases stdio are not closed and despite the process ending we do not react to it.
Additionally, I added clearing the timeout.
With these changes, looped tests for 6 hours did not cause any errors. The only difference is in the way of listening for the end of the spawned process.
onClose
waits for the bound stdio to end.onExit
does not wait for the stdio to close. Perhaps in some unspecified cases stdio are not closed and despite the process ending we do not react to it. Additionally, I added clearing the timeout.