Promise.all(promises).then(async (responses) => { for (...) { await new Promise(fulfill => stream.on("finish", fulfill)); //extract the text out of the PDF } })