bun icon indicating copy to clipboard operation
bun copied to clipboard

Using Nodemailer, sending emails in a loop only has ≅1/3 success rate

Open telesvar opened this issue 2 years ago • 6 comments

What version of Bun is running?

0.6.14

What platform is your computer?

Darwin 22.5.0 x86_64 i386

What steps can reproduce the bug?

Nodemailer version 6.9.3.

Using Nodemailer, I have found that sending emails fail frequently. The exact error Nodemailer reports is ECONNECTION pointing at bunConnect function in node:net package.

Made sure it is not throttling nor internet connection problem. Running exact same code in Node does not have the problem.

Transporter config is: { host: "smtp.gmail.com", secure: true, port: 465 }. Using { service: "gmail" } does not fix the problem.

Pseudocode:

for (const email of emails) {
	transporter.sendEmail({ ... });

	await delay(3000);
}

Stack trace:

Failed to send an email: 295 |       }).catch((error) => {
296 |         this.emit("error", error);
297 |       });
298 |     else
299 |
300 |       bunConnect({
         ^
error: Failed to connect
 code: "ECONNECTION"

      at connect (node:net:300:6)
      at /Users/aidarhanovs/Projects/formation/node_modules/nodemailer/lib/smtp-connection/index.js:321:35
      at /Users/aidarhanovs/Projects/formation/node_modules/nodemailer/lib/shared/index.js:117:19
      at /Users/aidarhanovs/Projects/formation/node_modules/nodemailer/lib/smtp-transport/index.js:264:12

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

telesvar avatar Jul 20 '23 15:07 telesvar

I'm commenting just because I think this library matters.

emastho avatar Jul 27 '23 09:07 emastho

have the same issue, with nodemailer and the error is "Failed to connect" for me as well.

i hope to see this issue get resolved because its a pretty important package.

TMBL-DEV avatar Sep 14 '23 11:09 TMBL-DEV

it probably has something to do with the fact that node:net is missing some stuff in bun

image

TMBL-DEV avatar Sep 14 '23 14:09 TMBL-DEV

Does this still reproduce for you?

nektro avatar May 10 '24 00:05 nektro

I don't know, I don't remember what project caused me to discover this bug.

I'll take a look today if I can reproduce it.

TMBL-DEV avatar May 15 '24 22:05 TMBL-DEV

Does this still reproduce for you?

I'll find exact same code that caused the issue and get back to you soon.

telesvar avatar May 15 '24 23:05 telesvar

Does this still reproduce for you?

I'll find exact same code that caused the issue and get back to you soon.

Yes? No?

7f8ddd avatar Jun 02 '24 09:06 7f8ddd

We have integration tests that run nodemailer in every PR

If you still run into connection errors, please let us know and we'll re-open it.

Jarred-Sumner avatar Aug 29 '24 02:08 Jarred-Sumner

Just tested my production server on Bun 1.1.27 and got similar issue. Sometimes emails sends but sometimes I'd get ETIMEDOUT (Connection timeout) error, sometimes ETIMEDOUT (Greeting never received).

After a while I put nodejs back and the problem disappeared. image

I tried to reproduce the bug on a local machine, but on local machine everything works good.

ziggi avatar Sep 18 '24 18:09 ziggi