It is not an infrequent trope in sci-fi shows for our protagonists to be struggling in their adventure, only to stumble across a seemingly nice self-sufficient society which they are welcomed into, but for it to be revealed later the society survives by cannibalising its own members/new recruits e.g. The Rain "Have Faith", Nightflyers "The Sacred Gift" etc (ep.4 of Vampire in the Garden is a variation).
What was the first story to feature this trope?