You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Darwin MacBook-Pro.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6031 arm64
Subsystem
No response
What steps will reproduce the bug?
Create a custom DNS lookup function that, instead of returning a string IP address, calls its callback with an array. For example:
constcustomLookup=(hostname,options,callback)=>{// Incorrectly return an array of IPs instead of a string.callback(null,["127.0.0.1"],options.family);};
Use this custom lookup in a network connection, for example:
importnetfrom'node:net';constoptions={host: 'example.com',port: 80,lookup: customLookup,family: 4// <- Trigger point, 4 or 6 can trigger the same};constsocket=net.connect(options,()=>{console.log("Connected!");});socket.on('error',(err)=>{console.error("Socket error:",err);});
Run the script using Node.js v23.4.0 on macOS.
How often does it reproduce? Is there a required condition?
It reproduces 100% of the time when using a custom DNS lookup that returns an array instead of a string as the address.
This requires running on Node.js v23.4.0 (and likely later versions) on Darwin. Not tested on other version, but likely can reproduce the same result.
What is the expected behavior? Why is that the expected behavior?
The DNS lookup callback should either return a valid string IP address or pass an error to the callback.
In other words, if the lookup returns an invalid type (like an array), Node.js should handle it gracefully—by invoking the callback with an error—rather than crashing.
This behavior is expected to ensure that user code can handle lookup errors consistently without encountering an internal assertion failure.
What do you see instead?
Instead of passing an error to the callback, Node.js crashes with an assertion error:
Thanks for your invitation, but I currently don't have much time to deeply inverstgate the problem and fix it since I have 4 project running concurrently.
Version
v23.4.0
Platform
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
It reproduces 100% of the time when using a custom DNS lookup that returns an array instead of a string as the address.
This requires running on Node.js
v23.4.0
(and likely later versions) onDarwin
. Not tested on other version, but likely can reproduce the same result.What is the expected behavior? Why is that the expected behavior?
The DNS lookup callback should either return a valid string IP address or pass an error to the callback.
In other words, if the lookup returns an invalid type (like an array), Node.js should handle it gracefully—by invoking the callback with an error—rather than crashing.
This behavior is expected to ensure that user code can handle lookup errors consistently without encountering an internal assertion failure.
What do you see instead?
Instead of passing an error to the callback, Node.js crashes with an assertion error:
Crash Log
Additional information
No response
The text was updated successfully, but these errors were encountered: