The solution is to analyze the transaction and determine how likely the transaction is going to confirm in the a few blocks. Generally you should look at the size of the transaction (a large transaction may be less likely to get into a block), the transaction fee per byte, the outputs (for dust outputs), whether the inputs are confirmed, and whether it signals Opt-in RBF. By examining these, you should be able to decide whether you think that transaction will confirm and whether you should accept it. If it opts-into RBF or spends unconfirmed inputs, you should wait for at least 1 confirmation as that transaction could be replaced.