Skip to content

typescript.sync_dns_lookup

Stability High

Detects synchronous DNS lookups that block the Node.js event loop.

Sync DNS lookups:

  • Block event loop — All requests stall
  • Unpredictable latency — DNS can take seconds
  • Causes timeouts — Other operations starved
// ❌ 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;
}
  • dns.lookupSync usage
  • Blocking network resolution
  • Sync operations in async context

Unfault can convert to async dns.lookup.