typescript.sync_dns_lookup
Stability
High
Detects synchronous DNS lookups that block the Node.js event loop.
Why It Matters
Section titled “Why It Matters”Sync DNS lookups:
- Block event loop — All requests stall
- Unpredictable latency — DNS can take seconds
- Causes timeouts — Other operations starved
Example
Section titled “Example”// ❌ Before (blocking DNS lookup)import { lookupSync } from 'dns';
function getHostIp(host: string): string { return lookupSync(host); // Blocks!}// ✅ After (async DNS resolution)import dns from 'dns/promises';
async function getHostIp(host: string): Promise<string> { const result = await dns.lookup(host); return result.address;}What Unfault Detects
Section titled “What Unfault Detects”- dns.lookupSync usage
- Blocking network resolution
- Sync operations in async context
Auto-Fix
Section titled “Auto-Fix”Unfault can convert to async dns.lookup.