Let A* fail but still return a path
https://coffeebraingames.wordpress.com/2018/12/29/let-a-fail-but-still-return-a-path/
I wrote an article before about avoiding pathfinding if you can determine beforehand that the destination is unreachable. This can be done by labeling your tiles or nodes with same integer value if they are connected. Before querying for a path, you can identify if a destination is reachable by checking if its label is the same as the starting position.