haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.02k stars 662 forks source link

helo.checks timeout crashes Haraka #3217

Closed lnedry closed 9 months ago

lnedry commented 1 year ago

Describe the bug

When this plugin has a timeout, it causes a Haraka worker to crash.

Expected behavior

This plugin should not cause a crash.

Observed behavior

Aug 17 13:20:15 mx4 haraka[269068]: [ERROR] [-] [Error] 
Aug 17 13:20:15 mx4 haraka[269068]: [CRIT] [-] [core] Error: timeout resolving: mta2.s.urbanoutfitters.com.
Aug 17 13:20:15 mx4 haraka[269068]: [CRIT] [-] [core]     at Timeout._onTimeout (/usr/lib/node_modules/Haraka/plugins/helo.checks.js:490:21)
Aug 17 13:20:15 mx4 haraka[269068]: [CRIT] [-] [core]     at listOnTimeout (node:internal/timers:569:17)
Aug 17 13:20:15 mx4 haraka[269068]: [CRIT] [-] [core]     at process.processTimers (node:internal/timers:512:7)
Aug 17 13:20:15 mx4 haraka[269068]: [NOTICE] [-] [core] Shutting down
Aug 17 13:20:15 mx4 haraka[265717]: [NOTICE] [-] [core] worker 59 exited with error code: 1
Aug 17 13:20:15 mx4 haraka[265717]: [NOTICE] [-] [core] worker started worker=61 pid=269178

System Info:

Haraka Haraka.js — Version: 3.0.1
Node v18.16.0
OS Linux mx4 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
openssl OpenSSL 1.1.1n 15 Mar 2022

Additional context

The name servers at exacttarget.com were having some problems for a few hours this morning.

msimerson commented 11 months ago

Try one of two things (which in the end, do the same thing):

  1. edit config/helo.checks.ini and set [main] dns_timeout=28

or

apply this patch:

diff --git a/plugins/helo.checks.js b/plugins/helo.checks.js
index b5a32147..bbe0f4ef 100644
--- a/plugins/helo.checks.js
+++ b/plugins/helo.checks.js
@@ -499,7 +499,7 @@ exports.get_a_records = async function (host) {
         err.code = dns.TIMEOUT;
         this.logerror(err);
         throw err;
-    }, (this.cfg.main.dns_timeout || 30) * 1000);
+    }, (this.cfg.main.dns_timeout || 28) * 1000);

     // fully qualify, to ignore any search options in /etc/resolv.conf
     if (!/\.$/.test(host)) host = `${host}.`;
lnedry commented 11 months ago

Thanks, Matt!

msimerson commented 9 months ago

I presume that solved the problem for you. If yes, a PR should be submitted with this change.

lnedry commented 1 month ago

The 28 second timeout did not resolve the issue.

Haraka 3.0.3 and Node v20.15.0

Aug  5 01:12:29 mx haraka[3652129]: [ERROR] [-] [Error] 
Aug  5 01:12:29 mx haraka[3652129]: [CRIT] [-] [core] Error: timeout resolving: o1988.em.email.learnfromaxons.com.
Aug  5 01:12:29 mx haraka[3652129]: [CRIT] [-] [core]     at Timeout._onTimeout (/etc/haraka/plugins/helo.checks.js:501:21)
Aug  5 01:12:29 mx haraka[3652129]: [CRIT] [-] [core]     at listOnTimeout (node:internal/timers:573:17)
Aug  5 01:12:29 mx haraka[3652129]: [CRIT] [-] [core]     at process.processTimers (node:internal/timers:514:7)
Aug  5 01:12:29 mx haraka[3652129]: [NOTICE] [-] [core] Shutting down
Aug  5 01:12:29 mx haraka[3652114]: [NOTICE] [-] [core] worker 4 exited with error code: 1
Aug  5 01:12:29 mx haraka[3652114]: [NOTICE] [-] [core] worker started worker=26 pid=3820020