Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantiate CacheableLookup only when needed #1529

Merged
merged 3 commits into from Nov 19, 2020
Merged

Instantiate CacheableLookup only when needed #1529

merged 3 commits into from Nov 19, 2020

Commits on Nov 19, 2020

  1. Instantiate CacheableLookup only when needed

    The `dnsCache` option is disabled by default but a `CacheableLookup` instance is always created. The proposed change is to instantiate CacheableLookup only when needed, which may make `got` a bit faster to load by default and when you do not use the DNS cache.
    
    Moreover, the CacheableLookup class instantiates the DNS [`Resolver` class in NodeJS the standard library](https://nodejs.org/api/dns.html#dns_class_dnspromises_resolver), and the test framework [Jest](https://github.com/facebook/jest/) has a problem with it. It wrongly detects that something keeps running after the tests are finished, while it's just an instance of the DNS Resolver class. See jestjs/jest#6423
    
    Jest should be fixed but meanwhile this small improvement in got may also hide the Jest issue for many developers.
    fungiboletus committed Nov 19, 2020
    Copy the full SHA
    f5fb0cf View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    e7e2077 View commit details
    Browse the repository at this point in the history
  3. Fix code style

    fungiboletus committed Nov 19, 2020
    Copy the full SHA
    b4440ed View commit details
    Browse the repository at this point in the history