Replace duplicated code for discarding a promise's result