You could say while player is off screen disable pathfinding and have the enemy move towards you with a bullet behaviour, or move to etc. And when you are both on screen then do pathfinding. I think it fails because pathfinding only works within the viewport so they won't find a nearest path that includes wrap.