You forgot to attach the distance matrix. So, I can only guess that some elements of it are missing or infinite. Can you please check that? Try with sum(is.infinite(x = cdist)), sum(is.na(x = cdist)) and sum(is.nan(x = cdist)).
If that doesn't solve your problem, can you please provide a REPRoducible EXample of your problem? It provides more specifics of your problem, and it helps others to understand what problem you are facing.
In case you don't know how to make a reprex, here's a great link:
Also, please share a small part of the dataset in a copy-paste friendly format.
The dput function is very handy, if you have stored the dataset in some R object.
In case you've your dataset on a spreadsheet, check out the datapasta package. Take a look at the following link: