feat(dns): added support for a custom lookup function; (#5339)#6
feat(dns): added support for a custom lookup function; (#5339)#6MitchLewis930 wants to merge 1 commit intopr_026_beforefrom
Conversation
📝 WalkthroughWalkthroughThis PR adds DNS lookup customization and address family configuration capabilities to axios. It introduces type definitions, a new callbackify utility for wrapping async functions, helper predicates for function type detection, HTTP adapter implementation for handling these options, and comprehensive tests with examples. Changes
Sequence DiagramsequenceDiagram
participant Client as User Code
participant Config as Axios Config
participant Adapter as HTTP Adapter
participant Callbackify as Callbackify Helper
participant LookupFn as Lookup Function
participant Transport as HTTP/HTTPS Transport
Client->>Config: Pass config with async lookup function
Config->>Adapter: Initialize HTTP adapter with config
Adapter->>Adapter: Destructure lookup and family from config
alt lookup is async function
Adapter->>Callbackify: Wrap async lookup with callbackify
Callbackify->>Callbackify: Check if function is async
Note over Callbackify: Create callback-style wrapper
else lookup is sync callback
Adapter->>Adapter: Use lookup as-is
end
Adapter->>LookupFn: Call lookup(hostname, options, callback)
LookupFn->>LookupFn: Resolve address and family
LookupFn->>Adapter: Return result via callback
Adapter->>Adapter: Normalize result to [ip, family] pair
Adapter->>Transport: Pass lookup and family in request options
Transport->>Transport: Use custom DNS resolver
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (8)
🧰 Additional context used🧬 Code graph analysis (3)index.d.ts (1)
lib/adapters/http.js (1)
index.d.cts (2)
🪛 Biome (2.3.13)lib/utils.js[error] 667-667: Do not shadow the global "constructor" property. Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global. (lint/suspicious/noShadowRestrictedNames) 🔇 Additional comments (11)
✏️ Tip: You can disable this entire section by setting Comment |
PR_026
Summary by CodeRabbit
New Features
familyconfiguration option (IPv4/IPv6) to customize address family for requests.lookupconfiguration option supporting both callback and promise-based custom DNS resolution.Tests
✏️ Tip: You can customize this high-level summary in your review settings.