NodeMCU loosing connection when attaching a servo

I think the servo.h library is a blocking function.
You should read this:

Pete.