• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

haraka / Haraka / 14223364357

02 Apr 2025 03:21PM UTC coverage: 62.767%. First build
14223364357

Pull #3456

github

web-flow
Merge 61270acf8 into 9686dc28a
Pull Request #3456: Fix crash when outbound connection fails

922 of 1398 branches covered (65.95%)

2 of 8 new or added lines in 1 file covered. (25.0%)

5403 of 8608 relevant lines covered (62.77%)

28.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

28.81
/outbound/client_pool.js
1
'use strict';
1✔
2

1✔
3
const util = require('node:util');
1✔
4

1✔
5
const utils = require('haraka-utils');
1✔
6
const net_utils = require('haraka-net-utils')
1✔
7

1✔
8
const tls_socket = require('../tls_socket');
1✔
9
const logger = require('../logger');
1✔
10
const obc  = require('./config');
1✔
11

1✔
12
exports.name = 'outbound'
1✔
13

1✔
14
// Get a socket for the given attributes.
1✔
15
exports.get_client = function (mx, callback) {
1✔
16
    const socketArgs = mx.path ? { path: mx.path } : { port: mx.port, host: mx.exchange, localAddress: mx.bind };
×
17

×
18
    const socket = tls_socket.connect(socketArgs);
×
19
    net_utils.add_line_processor(socket);
×
20

×
21
    socket.name = `outbound::${JSON.stringify(socketArgs)}`;
×
22
    socket.__uuid = utils.uuid();
×
23
    socket.setTimeout(obc.cfg.connect_timeout * 1000);
×
24

×
25
    logger.debug(exports, `created ${socket.name}`, { uuid: socket.__uuid });
×
26

×
27
    socket.once('connect', () => {
×
28
        socket.removeAllListeners('error'); // these get added after callback
×
29
        socket.removeAllListeners('timeout');
×
30
        callback(null, socket);
×
31
    })
×
32

×
33
    socket.once('error', err => {
×
34
        socket.end();
×
35
        socket.removeAllListeners();
×
36
        socket.destroy();
×
NEW
37
        const errMsg = err.message ?
×
NEW
38
            err.message :
×
NEW
39
            err instanceof AggregateError ?
×
NEW
40
                err.map(e => e.message).join(', ') :
×
NEW
41
                util.inspect(err, { depth: 3 });
×
NEW
42
        callback(errMsg, null);
×
43
    })
×
44

×
45
    socket.once('timeout', () => {
×
46
        socket.end();
×
47
        socket.removeAllListeners();
×
48
        socket.destroy();
×
49
        callback(`connection timed out to ${socket.name}`, null);
×
50
    })
×
51
}
×
52

1✔
53
exports.release_client = (socket, mx) => {
1✔
54
    let logMsg = `release_client: ${socket.name}`
×
55
    if (mx.bind) logMsg += ` from ${mx.bind}`
×
56
    logger.debug(exports, logMsg);
×
57
    socket.removeAllListeners();
×
58
    socket.destroy();
×
59
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc