Skip to content

dns lookup is not cached the way I understand #67

@menocomp

Description

@menocomp

Hello there,

I could be missing something here.

I am trying to reduce the calls that go to dns.lookup in order to reduce the C++ libuv threads allocation so I am using this library.

How I am testing that, by running this code:

const nodeDnsLookup = dns.lookup;
let dnsLookupCounter = 0;
dns.lookup = (...args) => {
  console.log(`I am calling the native node dns lookup ${JSON.stringify(args)}, number ${dnsLookupCounter}`);
  dnsLookupCounter++;
  return nodeDnsLookup(...args);
};

so, without installing this library I can see a lot of dns lookups.

Now after I installed this library with its global http(s) agent as follows:

import CacheableLookup from 'cacheable-lookup';
const cacheable = new CacheableLookup();

cacheable.install(http.globalAgent);
cacheable.install(https.globalAgent);

I was expecting the number of dns lookups would go down and cache hits to happen, but it did not!
I see from the logs that the same hostname with the same family are still calling the native dns.lookup and not served from a cache.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions