diff --git a/lib/mbox-export.js b/lib/mbox-export.js index f75a57d2..60785116 100644 --- a/lib/mbox-export.js +++ b/lib/mbox-export.js @@ -43,19 +43,19 @@ async function mboxExport(auditHandler, audit) { setImmediate(() => { processExport() - .catch(err => { - try { - outputStream.write('\n' + err.message); - } catch (err) { - //ignore - } - }) - .finally(() => { + .then(() => { try { outputStream.end(); } catch (err) { // ignore at this point } + }) + .catch(err => { + try { + outputStream.end('\n' + err.message); + } catch (err) { + //ignore + } }); });