Using Nodemailer, sending emails in a loop only has ≅1/3 success rate
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
I'm commenting just because I think this library matters.
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.
it probably has something to do with the fact that node:net is missing some stuff in bun
Does this still reproduce for you?
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.
Does this still reproduce for you?
I'll find exact same code that caused the issue and get back to you soon.
Does this still reproduce for you?
I'll find exact same code that caused the issue and get back to you soon.
Yes? No?
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.
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.
I tried to reproduce the bug on a local machine, but on local machine everything works good.