Value error: 'MODE_UNINITIALIZED' is not initialized to a value

Hello. I am using ur robot driver and external control to control UR robot from ROS, but I am getting this error while running it:

Value error: 'MODE_UNINITIALIZED' is not initialized to a value

It looks like the error occurs only when external control in the first loop is skipped and external control in the second loop is executed first.

This is a demonstration to show how the process looks like: