npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-dns-bugfix

v1.0.1

Published

Patch for NodeJS bug where calling `dns.setServers` during `dns.resolve*` being in progress causes Node process to crash with: ``` node: ../deps/cares/src/ares_destroy.c:102: ares__destroy_servers_state: Assertion `ares__is_list_empty(&server->queries_to

Downloads

23

Readme

node-dns-bugfix

Patch for NodeJS bug where calling dns.setServers during dns.resolve* being in progress causes Node process to crash with:

node: ../deps/cares/src/ares_destroy.c:102: ares__destroy_servers_state: Assertion `ares__is_list_empty(&server->queries_to_server)' failed.
Aborted (core dumped)

Some links:

Compatibility

You don't need that for

  • Node 10+
  • Node 9.3.0+ (but you need it for Node < 9.3.0)
  • Node 8.10.0+ (but you need it for Node < 8.10.0)

(you will be warned if imported in your code in these versions)

Tested to work (fixes the bug) with

  • Node 6.14.3
  • Node 9.2.1

Does not work with

Issue seems to be even bigger in these versions.

  • Node 4.9.1
  • Node 5.12.0
  • Node 7.10.1

How it works

The fix monkey patches setServers and resolve functions of dns module. This makes new setServer calls to wait for all resolve to finish. After last resolve is done it updates the servers settings if setServers was called while resolving.

Note that this causes differences between real Node bugfix and this monkey patch behavior:

  • Monkey patched version will not update dns servers until all resolved are completed. If you call resolve always before last one finishes - dns servers may never be updated and Node will be resolving with old servers forever. This is VERY edge-case, but I want you to know that it is possible.
  • Real patched Node versions (9.3.0 and up) should use newest servers set with every resolve.

Usage

Do this as soon as possible in your code:

require("node-dns-bugfix");

You will be warned with console if used with Node version that has this fixed already. No patching will occur.

ES5

For Node v6 you probably need to import ES5 version of the code:

require("node-dns-bugfix/dist");

Test

Test files are contained in test directory. Run should-crash.js on broken Node version to see process crash. Run should-not-crash.js on broken Node version to see how this fix prevents the crash.

On fixed Node versions (8.10+, 9.3+) both scripts won't cause crash, but should-not-crash will trigger a warning.

To do

  • Make it work with unsupported Node versions? At least for v.4+.

License

MIT