I think I find something useful for fixing the bug.
This bug was caused by Chinese Input Method. I installed Chinese Input Method into a MacBook Pro (2016) with Japanese Keyboard Layout. After running a script, if I clicked command window immediately under Chinese Input Method, the error messages will appear.
After running a script, before clicking the command window,
change your input method to any other input methods if your current method is Chinese;
or click one of the other window blocks first, such as workspace.