Registry / devops / axios-cached-dns-resolve

axios-cached-dns-resolve

JSON →
library3.3.0jsnpmunverified

Axios interceptor that replaces synchronous dns.lookup with async dns.resolve, with optional caching and background refresh. Version 3.3.0 targets Node >=14, ships TypeScript types, and uses ESM only. Key differentiators: configurable TTL, idle eviction, round-robin across resolved IPs, and built-in statistics. Designed for Kubernetes/cloud environments where low DNS TTLs overwhelm default synchronous resolution.

npm install axios-cached-dns-resolve
INSTALL
IMPORT
SIG · AXIOS-CACHED-DNS-R
A
axios-cached-dns-resolve
devopsjavascriptv3.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

registerInterceptor
import { registerInterceptor } from 'axios-cached-dns-resolve'
const { registerInterceptor } = require('axios-cached-dns-resolve')
ESM-only package; require() will fail.
getStats
import { getStats } from 'axios-cached-dns-resolve'
Named export, not default.
getDnsCacheEntries
import { getDnsCacheEntries } from 'axios-cached-dns-resolve'
Named export, returns array of cache entry objects.
default export
import axiosCachedDnsResolve from 'axios-cached-dns-resolve'
No default export exists; all exports are named.

Creates an Axios client and registers the DNS caching interceptor with custom TTL and cache size.

import axios from 'axios'; import { registerInterceptor } from 'axios-cached-dns-resolve'; const client = axios.create({ baseURL: 'https://example.com' }); registerInterceptor(client, { dnsTtlMs: 5000, dnsCacheSize: 100, }); client.get('/api/data').then(response => { console.log(response.data); }).catch(err => { console.error(err.message); });
Debug
Known issues
breakingPackage is ESM-only since v3.0.0.
fix
Use import syntax; set type: module in package.json or use .mjs extension.
affects: >=3.0.0
breakingNode.js <14 not supported as of v3.0.0.
fix
Upgrade to Node 14 or later.
affects: >=3.0.0
deprecatedConfiguration via environment variables has precedence; ensure env vars are not set unintentionally.
fix
Explicitly pass config object to registerInterceptor() avoid reading env vars.
affects: >=1.0.0
gotchaCache key mismatch: registerInterceptor must be called once per Axios instance. Reusing config across instances may cause unexpected behavior.
fix
Call registerInterceptor for each axios.create() instance separately.
affects: >=1.0.0
gotchaLogging uses pino; if not configured, default logging level is 'info'. Set logging.level to 'error' or disable logging in production.
fix
In config: logging: { level: 'error' } or disabled: true.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to require() an ESM-only module in CommonJS context.
fix
Use import syntax: import { registerInterceptor } from 'axios-cached-dns-resolve'
TypeError: axiosClient.interceptors.request.use is not a function
registerInterceptor was called without a valid Axios instance.
fix
Ensure the argument is an Axios instance (created with axios.create()).
AxiosError: getaddrinfo ENOTFOUND
DNS resolution failure; cached entries may be stale or host unreachable.
fix
Check network connectivity, or disable cache with { disabled: true } to fall back to default lookup.
Upgrade
Version history
3.3.0latest on npm
Audit
Dependencies
pinooptionalLogging (optional, via logging config)
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
axios-cached-dns-resolve — npm install axios-cached-dns-resolve · libregistry