Skip to content

Commit 0012135

Browse files
committed
Fix crash when outbound connection fails
In node 22 atleast, network code has started returning AggregateError. This means that when socket connection fails, err.message is an empty string. The on('error') handler as a result invoked callback('', null) . Since error is falsy, code assumes socket is valid and crashes. Code is changed to always return a error string. Fixes #3455
1 parent 9686dc2 commit 0012135

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ exports.get_client = function (mx, callback) {
3232
socket.end();
3333
socket.removeAllListeners();
3434
socket.destroy();
35-
callback(err.message, null);
35+
callback(err ? `socket error to ${socket.name}: ${err.message} ${err.code}` : null, null);
3636
})
3737

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

0 commit comments

Comments
 (0)