-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
net: emit an error when custom lookup resolves a non-string address #57192
net: emit an error when custom lookup resolves a non-string address #57192
Conversation
Review requested:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #57192 +/- ##
==========================================
- Coverage 90.33% 90.26% -0.07%
==========================================
Files 630 630
Lines 184537 184634 +97
Branches 36077 36125 +48
==========================================
- Hits 166693 166653 -40
- Misses 10950 11028 +78
- Partials 6894 6953 +59
|
The "throw" word is a bit misleading, no error is thrown. |
Got it. Would you have a suggestion? |
How about "handle" or "emit" an error? |
yeah, much better. Thank you |
Would you mind fixing the first commit message as well? |
nice catch. will do |
62885b9
to
831b908
Compare
Done. I squashed into a single commit :) |
One final nit, feel free to ignore: |
Could you add a |
a5ba0b1
to
b6ff5b2
Compare
The last push was just one more squash - and to run the CI now it's fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not coerce to string nor use isStringObject
.
Would you have a suggestion? |
b6ff5b2
to
94c760a
Compare
@@ -1416,7 +1416,7 @@ function lookupAndConnect(self, options) { | |||
// calls net.Socket.connect() on it (that's us). There are no event | |||
// listeners registered yet so defer the error event to the next tick. | |||
process.nextTick(connectErrorNT, self, err); | |||
} else if (!isIP(ip)) { | |||
} else if ((typeof ip !== 'string') || !isIP(ip)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we handle this inside isIp() function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a point. I think this is reasonable to have this inside of isIP
. Let me check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isIP
is a public API. It would be a breaking change to do it.
Landed in 71196c4 |
PR-URL: #57192 Fixes: #57112 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Fixes: #57112
This PR fixes the crash when the lookup function resolves to a non-string address. Instead, it will emit an ERR_INVALID_IP_ADDRESS error.