Yes, this can be a real problem.
The mortgage company that we chose had a program where they did all of the underwriting before we even started making offers, and part of our offer was a certificate entitling the seller to $5000 at the mortgage company's expense if we couldn't get financing. Kind of like extra earnest money from the mortgage company offered as a guarantee that there wouldn't be any problems in closing.
We ended up getting the first house we made an offer on in spite of an insane market, so I guess it worked!