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

haraka / Haraka / 14189245291

01 Apr 2025 06:58AM UTC coverage: 62.795%. First build
14189245291

Pull #3456

github

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

922 of 1398 branches covered (65.95%)

0 of 1 new or added line in 1 file covered. (0.0%)

5401 of 8601 relevant lines covered (62.8%)

28.16 hits per line

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

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

1✔
3
const utils = require('haraka-utils');
1✔
4
const net_utils = require('haraka-net-utils')
1✔
5

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

1✔
10
exports.name = 'outbound'
1✔
11

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

×
16
    const socket = tls_socket.connect(socketArgs);
×
17
    net_utils.add_line_processor(socket);
×
18

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

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

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

×
31
    socket.once('error', err => {
×
32
        socket.end();
×
33
        socket.removeAllListeners();
×
34
        socket.destroy();
×
NEW
35
        callback(err ? `socket error to ${socket.name}: ${err.message} ${err.code}` : null, null);
×
36
    })
×
37

×
38
    socket.once('timeout', () => {
×
39
        socket.end();
×
40
        socket.removeAllListeners();
×
41
        socket.destroy();
×
42
        callback(`connection timed out to ${socket.name}`, null);
×
43
    })
×
44
}
×
45

1✔
46
exports.release_client = (socket, mx) => {
1✔
47
    let logMsg = `release_client: ${socket.name}`
×
48
    if (mx.bind) logMsg += ` from ${mx.bind}`
×
49
    logger.debug(exports, logMsg);
×
50
    socket.removeAllListeners();
×
51
    socket.destroy();
×
52
}
×
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