nodemailer / smtp-server

Create custom SMTP servers on the fly
Other
846 stars 145 forks source link

Cannot call write after a stream was destroyed #155

Open niftylettuce opened 3 years ago

niftylettuce commented 3 years ago

If you have an onData handler and at the top of it put this, then the following error occurs:

onData(stream, session, fn) {
  stream.once('error', fn);
  stream.destroy(new Error('Oops'));
}
15|smtp    | Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
15|smtp    |     at doWrite (_stream_writable.js:437:19)
15|smtp    |     at writeOrBuffer (_stream_writable.js:425:5)
15|smtp    |     at PassThrough.Writable.write (_stream_writable.js:316:11)
15|smtp    |     at PassThrough.Writable.end (_stream_writable.js:623:10)
15|smtp    |     at SMTPStream._endDataMode (/var/www/production/source/node_modules/smtp-server/lib/smtp-stream.js:257:30)
15|smtp    |     at SMTPStream._feedDataStream (/var/www/production/source/node_modules/smtp-server/lib/smtp-stream.js:175:30)
15|smtp    |     at SMTPStream._write (/var/www/production/source/node_modules/smtp-server/lib/smtp-stream.js:133:18)
15|smtp    |     at doWrite (_stream_writable.js:441:12)
15|smtp    |     at writeOrBuffer (_stream_writable.js:425:5)
15|smtp    |     at SMTPStream.Writable.write (_stream_writable.js:316:11)