I have experienced this issue as well. It can happen anywhere in game. The issue is the server response to your NPC interaction is dropped. The nature of traffic between you and the server is lossy, with no guaranteed delivery. So, this issue is always possible unfortunately.
How to fix it? Or prevent it permanently? I have no idea.