Skip to content

Comments

feat(dns): added support for a custom lookup function; (#5339)#6

Open
MitchLewis930 wants to merge 1 commit intopr_026_beforefrom
pr_026_after
Open

feat(dns): added support for a custom lookup function; (#5339)#6
MitchLewis930 wants to merge 1 commit intopr_026_beforefrom
pr_026_after

Conversation

@MitchLewis930
Copy link

PR_026

@MitchLewis930 MitchLewis930 requested a review from Copilot January 31, 2026 00:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for custom DNS lookup functions in the HTTP adapter, allowing users to override the default DNS resolution behavior when making HTTP requests.

Changes:

  • Added new utility functions to detect async functions and thenable objects
  • Created a callbackify helper to convert async functions to callback-based functions
  • Modified the HTTP adapter to accept and process custom lookup and family configuration options

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/utils.js Added utility functions for detecting function types (async, generator) and thenable objects
lib/helpers/callbackify.js New helper to convert async functions to callback-based functions for DNS lookup compatibility
lib/adapters/http.js Integrated custom lookup function support with automatic async-to-callback conversion
index.d.cts Added TypeScript type definitions for the new family and lookup configuration options
test/unit/adapters/http.js Added comprehensive tests for custom DNS lookup functionality including callback and async variants
test/module/typings/esm/index.ts Added TypeScript usage examples for the new lookup configuration

if(utils.isString(entry)) {
entry = [entry, entry.indexOf('.') < 0 ? 6 : 4]
} else if (!utils.isArray(entry)) {
throw new TypeError('lookup async function must return an array [ip: string, family: number]]')
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

The error message contains an extra closing bracket. The text should be 'an array [ip: string, family: number]' with only one closing bracket.

Suggested change
throw new TypeError('lookup async function must return an array [ip: string, family: number]]')
throw new TypeError('lookup async function must return an array [ip: string, family: number]')

Copilot uses AI. Check for mistakes.
} catch (err) {
cb(err);
}
}, cb);
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

When the promise rejects (line 12), the callback receives the raw rejection reason which may not have a meaningful error message. Consider wrapping the rejection in a descriptive error or ensuring the rejection value is always an Error object.

Suggested change
}, cb);
}, (reason) => {
const error = reason instanceof Error ? reason : new Error(String(reason));
cb(error);
});

Copilot uses AI. Check for mistakes.

if (lookup && utils.isAsyncFn(lookup)) {
lookup = callbackify(lookup, (entry) => {
if(utils.isString(entry)) {
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Missing space after 'if' keyword. The code should follow consistent spacing conventions: if (utils.isString(entry)).

Suggested change
if(utils.isString(entry)) {
if (utils.isString(entry)) {

Copilot uses AI. Check for mistakes.
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.

2 participants