Oops, I forgot to disable the debugging functions before release. Thanks for pointing that out.
Please leave version 2.1.2 installed and continue playing despite the console messages until the problem occurs again. Then please send me the factorio-current.log file. The messages are also logged there, and I may be able to use them to figure out what is going wrong for you. I have reintegrated the old query into version 2.1.2. That should have fixed the problem.
You can also post the file in the forum under the thread for my post: https://forums.factorio.com/viewtopic.php?t=79205
Or send me the file via PM in the Factorio forum. My username there is picklock.
Thank you for your support and apologies for the inconvenience.