Skip to content

Commit 93d9998

Browse files
authored
Fix crash when outbound connection fails (#3456)
In node 20 & 22 network code has started returning AggregateError. Code is changed to always return a string.
1 parent 9686dc2 commit 93d9998

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Changes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
44

55
### Unreleased
66

7+
- fix(outbound): in outbound, fix a crash when socket connection errors #3456
8+
79
### [3.1.0] - 2025-01-30
810

911
#### Changes

outbound/client_pool.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const util = require('node:util');
4+
35
const utils = require('haraka-utils');
46
const net_utils = require('haraka-net-utils')
57

@@ -32,7 +34,12 @@ exports.get_client = function (mx, callback) {
3234
socket.end();
3335
socket.removeAllListeners();
3436
socket.destroy();
35-
callback(err.message, null);
37+
const errMsg = err.message ?
38+
err.message :
39+
err instanceof AggregateError ?
40+
err.map(e => e.message).join(', ') :
41+
util.inspect(err, { depth: 3 });
42+
callback(errMsg, null);
3643
})
3744

3845
socket.once('timeout', () => {

0 commit comments

Comments
 (0)