Turns out it wasn’t actually hanging—the findOne inside a loop of over 2000 items was just extremely slow. I figured this out by adding mongoose.set("debug", true); after mongoose.connect(), which revealed that Mongoose was making a separate query for each vacancy, causing a massive slowdown.
The fix was simple: instead of querying the database repeatedly, I fetched all existing entries at once using Model.find({}, "vacancyId") and stored them in an array for fast lookups in memory.