diff --git a/index.js b/index.js index 53074845a..4482095cc 100644 --- a/index.js +++ b/index.js @@ -106,14 +106,18 @@ function makeAllStream(spawned) { return mixed; } -function getBufferedData(stream, streamPromise) { +async function getBufferedData(stream, streamPromise) { if (!stream) { return; } stream.destroy(); - return streamPromise.catch(error => error.bufferedData); + try { + return await streamPromise; + } catch (error) { + return error.bufferedData; + } } function getStream(process, stream, {encoding, buffer, maxBuffer}) {