Got: cacheable-lookup can cause DNSCHANNEL to remain open even when dnsCache is not being used

Created on 1 Sep 2020  ·  8Comments  ·  Source: sindresorhus/got

Describe the bug

Actual behavior

With above versions of node, jest, and nock, this sometimes happens:

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  DNSCHANNEL

      at new CacheableLookup (node_modules/cacheable-lookup/source/index.js:75:14)
      at Object.<anonymous> (node_modules/got/dist/source/core/index.js:29:24)
      at Object.<anonymous> (node_modules/got/dist/source/as-promise/types.js:16:16)

This change is causing the dns cache to always be created even when dnsCache is not true, and it never shuts down:
Fix dnsCache: true having no effect: https://github.com/sindresorhus/got/commit/043c9501b85172e09819d44ac8eb49c574b27bda

Expected behavior

  • Only call new CacheableLookup(); when options.dnsCache === true. Maybe use mem to memoize it so it's not re-generated on every call.
  • Don't prevent Jest (or other processes) from exiting.

Code to reproduce

https://github.com/facebook/jest/issues/6423

Checklist

  • [x] I have read the documentation.
  • [x] I have tried my code with the latest version of Node.js and Got.
external wontfix

Most helpful comment

I have the same problem:

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  DNSCHANNEL

      at new CacheableLookup (../../node_modules/cacheable-lookup/source/index.js:75:14)
      at Object.<anonymous> (../../node_modules/got/dist/source/core/index.js:32:24)
      at Object.<anonymous> (../../node_modules/got/dist/source/as-promise/types.js:14:16)

All 8 comments

It doesn't prevent the process from exiting. If it did then our tests would time out. This is definitely a bug in Jest.

You can simply test it via:

node -e "new (require('dns').Resolver)().resolve4('google.com', console.log)"

Also this is a duplicate of #1397

Thanks for the quick reply @szmarczak! Sorry to take your time!

No problem. Let me know if there are any other issues :)

Also I think you can disable that check in Jest as a workaround.

I have the same problem:

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  DNSCHANNEL

      at new CacheableLookup (../../node_modules/cacheable-lookup/source/index.js:75:14)
      at Object.<anonymous> (../../node_modules/got/dist/source/core/index.js:32:24)
      at Object.<anonymous> (../../node_modules/got/dist/source/as-promise/types.js:14:16)

Same for me.

There's nothing we can do. Locking.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carvallegro picture carvallegro  ·  4Comments

khizarsonu picture khizarsonu  ·  3Comments

joolfe picture joolfe  ·  3Comments

jamestalmage picture jamestalmage  ·  3Comments

framerate picture framerate  ·  4Comments