Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: write after end #205

Closed
cosmicdust471 opened this issue Oct 4, 2017 · 9 comments
Closed

Error: write after end #205

cosmicdust471 opened this issue Oct 4, 2017 · 9 comments

Comments

@cosmicdust471
Copy link

cosmicdust471 commented Oct 4, 2017

Hello everyone.

I'am getting this error, and I can´t find anywhere what it means. I have a node app that sends an array of emails and at some point this error ocurrs. Does anyone know what does it mean?

Error: write after end
    at writeAfterEnd (_stream_writable.js:236:12)
    at TLSSocket.Writable.write (_stream_writable.js:287:5)
    at TLSSocket.Socket.write (net.js:697:40)
    at SMTP.send (/app/node_modules/emailjs/smtp/smtp.js:186:17)
    at SMTP.command (/app/node_modules/emailjs/smtp/smtp.js:212:10)
    at SMTP.rset (/app/node_modules/emailjs/smtp/smtp.js:364:10)
    at check (/app/node_modules/emailjs/smtp/client.js:156:23)
    at caller (/app/node_modules/emailjs/smtp/smtp.js:48:14)
    at response (/app/node_modules/emailjs/smtp/smtp.js:198:9)
    at caller (/app/node_modules/emailjs/smtp/smtp.js:48:14)

This is my code:

server.send({
	text:    send_array[idx].client_email, 
	from:    sender_email, 
	to:      send_array[idx].client_to,
	cc:      '',
	bcc:     "[email protected]",
	subject: send_array[idx].client_subject + ' SID:' + idx,
	attachment: attachments
}, function(err, message) { 
        //send the next email if there is any
});	 

Thanks!

@ysilvela
Copy link

Me too. This error appear a few days ago.

@eleith
Copy link
Owner

eleith commented Oct 29, 2017

what version of node are you running?

@eleith
Copy link
Owner

eleith commented Oct 29, 2017

can you turn on debugging? (uncomment this line: https:/eleith/emailjs/blob/master/smtp/client.js#L9)

it looks like for some reason you are sending a RSET because the SMTP server hit an error and likely closed, but the closing got missed by this library somehow.

@terbooter
Copy link

Same error

$ node server\dist\test-email.js
Email {
  config:
   { host: 'smtp.sparkpostmail.com',
     port: 587,
     user: 'SMTP_Injection',
     password: 'a........................c',
     tls: true } }
connecting: smtp.sparkpostmail.com:587
connected: smtp.sparkpostmail.com:587
220 2.0.0 smtp.sparkpostmail.com ESMTP ecelerity 4.2.38.62433 r(:) Tue, 02 Jan 2018 14:31:50 +0000

ehlo cosmos

250-b.mta1vsmtp.cc.aws-usw2b.prd.sparkpost says EHLO to 95.31.111.8:55912
250-8BITMIME
250-ENHANCEDSTATUSCODES
250-AUTH=LOGIN PLAIN
250-AUTH LOGIN PLAIN
250-PIPELINING
250 STARTTLS

starttls

ehlo cosmos

helo cosmos

smtp connection destroyed!
{ Error: connection encountered an error (write after end)
    at module.exports ... \node_modules\emailjs\smtp\error.js:2:13)

@eleith
Copy link
Owner

eleith commented Feb 9, 2018

so somewhere along the lines, close(true) was called. any chance you can do some more debugging to determine which one was called?

for example, was it this one? https:/eleith/emailjs/blob/master/smtp/smtp.js#L164

@tjrhodes
Copy link

Getting masses of these errors, out of 170 mails, only 3 just got sent, rest were all "Error: connection encountered an error (write after end)" or "Error: write after end". Node 8.11.3
, getting them to non gmail and gmail smtp servers.

@zackschuster
Copy link
Collaborator

can anyone here verify these issues are still occurring?

@zackschuster
Copy link
Collaborator

this should be fixed by 81e78bf

will re-post when that has been released.

@zackschuster
Copy link
Collaborator

3.3.0 has been release with this fix 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants