10000 Fix crash when outbound connection fails by gramakri · Pull Request #3456 · haraka/Haraka · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix crash when outbound connection fails #3456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025

Conversation

gramakri
Copy link
Collaborator
@gramakri gramakri commented Apr 1, 2025

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

Changes proposed in this pull request:

  • Code is changed to always return a error string on a socket error

Checklist:

  • docs updated
  • tests updated
  • Changes updated

@gramakri gramakri force-pushed the fix_outbound_crash branch 2 times, most recently from a765afc to 0012135 Compare April 1, 2025 06:58
@gramakri gramak 8000 ri requested a review from msimerson April 1, 2025 07:01
@gramakri gramakri self-assigned this Apr 1, 2025
@msimerson
Copy link
Member

Hmmm, this might be related to a new [ buggy / suboptimal ] connection startup in node.js.

My first thought with this change is that there's a multitude of reasons why a connection might fail, and a static error message will tend to mask the specifics. Perhaps testing err with err instanceof AggregateError would be better, and if it's an aggregate error, return the first error message (err.errors[0].message)?

@msimerson
Copy link
Member

Or perhaps something more like this...

const errMsg = err.message ? err.message :
	err instanceof AggregateError ? err.map(e => e.message).join(', ') :
	util.inspect(err { depth: 3 });

Testing this code with some of the actual errors see In The Wild[TM] would likely suggest a refinement or two.

@gramakri
Copy link
Collaborator Author
gramakri commented Apr 2, 2025

Thanks for your excellent input as always @msimerson . I will update the PR .

The reason the connection fails is because of the domain has a MX record which just has "." in it and nothing else :/ I guess there is a myriad of ways to put invalid hostnames in DNS . This makes the connection fail and unfortunately haraka keeps crashing .

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 haraka#3455
@gramakri gramakri force-pushed the fix_outbound_crash branch from 0012135 to 61270ac Compare April 2, 2025 15:21
Copy link
Member
@msimerson msimerson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me!

@msimerson msimerson merged commit 93d9998 into haraka:master Apr 2, 2025
11 of 12 checks passed
@gramakri gramakri deleted the fix_outbound_crash branch April 3, 2025 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash in outbound when connection fails
2 participants
0