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

Support custom DNS IP and DNS failover IP using custom DNS resolver #685

Merged

Conversation

ghengeveld
Copy link
Member

@ghengeveld ghengeveld commented Nov 30, 2022

  • Added CHROMATIC_DNS_SERVERS environment variable to support custom DNS IP addresses.
  • On ENOTFOUND error, automatically switch to using a custom DNS resolver that doesn't rely on OS-level DNS
  • Added CHROMATIC_DNS_FAILOVER_SERVERS environment variable use when we still encounter ENOTFOUND even using the custom DNS resolver.

@linear
Copy link

linear bot commented Nov 30, 2022

AP-2314 Allow Customers To Override DNS When 'ENOTFOUND' Errors Are Returned From The Chromatic CLI

What

From time to time, customers encounter DNS lookup errors, typically on Macs, where the CLI can resolve index.chromatic.com until it can't. When this happens, the CLI will eventually return a getaddrinfo ENOTFOUND error and the customer cannot complete a build. Yann has run across this before as well.

Why

When Node passes the DNS lookup to the host OS, most of the time it simply works. But there are times when that DNS simply fail. The getaddrinfo part of the error message means that it is failing outside of Node down somewhere in the OS system libraries. Additionally, the HTTP package leverages this host API call but does have a way to override it.

How

The proposed solution would be to allow customers to set an environment variable to configure DNS servers that the CLI would use. There is a branch out on the CLI's repo that hard codes DNS to 1.1.1.1 and 4.4.4.4, cacheable-lookup. This branch fixed Yann's DNS issue. (link)

Copy link
Contributor

@jmhobbs jmhobbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like having both options to override default and still have a fail over.

There's no cache built into Node direct DNS, do we want to add a layer or just accept the extra lookups will happen?

@brockwood
Copy link

There's no cache built into Node direct DNS, do we want to add a layer or just accept the extra lookups will happen?

That is a good idea and there are packages that will wrap the dns.resolve call that we could use: https://www.npmjs.com/package/axios-cached-dns-resolve

@ghengeveld
Copy link
Member Author

I looked at axios-cached-dns-resolve, but since we don't use Axios, I don't think we can use it. I briefly looked for a lower-level alternative, but didn't find an obvious candidate. Considering the limited amount of requests we actually do (assuming the use of --zip), I think it's not a big enough concern to address right now.

@ghengeveld ghengeveld requested a review from jmhobbs December 6, 2022 12:51
@ghengeveld ghengeveld force-pushed the ghengeveld/ap-2314-allow-customers-to-override-dns-when branch 3 times, most recently from 6e2fda0 to d0fd194 Compare December 9, 2022 13:43
@ghengeveld ghengeveld merged commit 7a45e4b into main Dec 9, 2022
@ghengeveld ghengeveld deleted the ghengeveld/ap-2314-allow-customers-to-override-dns-when branch December 9, 2022 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants