fix(dns): fall back to public resolver when system DNS is unreachable - #15
Open
BabyBear7 wants to merge 2 commits into
Open
fix(dns): fall back to public resolver when system DNS is unreachable#15BabyBear7 wants to merge 2 commits into
BabyBear7 wants to merge 2 commits into
Conversation
Merged
3 tasks
BabyBear7
force-pushed
the
fix/srv-fallback-node22
branch
from
April 14, 2026 14:33
d1147d7 to
7af46e9
Compare
When the system DNS resolver is unreachable (e.g. the Node.js 22 + Windows c-ares regression tracked in nodejs/node#62326, where c-ares reports the loopback fallback with port 53 and Node misdetects it as a real nameserver), resolveSrv rejects with ECONNREFUSED and getServerStatus silently falls back to the default 25565 port. For servers configured only through SRV records this makes them appear permanently offline. Retry the SRV query against 1.1.1.1 / 8.8.8.8 with an explicit Resolver when the first attempt fails with a network-layer error code. Legitimate "no SRV record" responses (ENOTFOUND, ENODATA, etc.) still short-circuit to null so this only costs an extra lookup in the broken-resolver case.
BabyBear7
force-pushed
the
fix/srv-fallback-node22
branch
from
April 14, 2026 14:42
7af46e9 to
a88ffd3
Compare
Add an inline comment near the gating check in checkSrv explaining why ESERVFAIL / EREFUSED are deliberately excluded from the fallback allowlist (they are legitimate resolver outcomes including policy responses, so retrying against a public resolver would silently bypass local DNS policy). Runtime behavior unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
checkSrvcurrently swallows every error and returnsnull, which meansgetServerStatussilently falls back to the default 25565 port whenever the system DNS resolver is broken. For servers that expose their Minecraft port only through SRV records, this makes them show as permanently offline even though the server is up.This showed up in the wild with the Node.js 22 + Windows c-ares regression tracked in nodejs/node#62326 / #62347. Newer c-ares (bundled in Node 22.22.0, 24.13.0+, 25.x < 25.6.1) reports the loopback fallback with
tcp_port/udp_port = 53instead of0. Node's glue layer still checks for port0to detect the fallback, misdetects, and ends up firing DNS queries at127.0.0.1:53which has no listener — henceECONNREFUSED querySrv. The fix (nodejs/node#61453) is in 25.6.1 and 24.x but not yet backported to the 22 LTS line, so Electron apps on Electron 39 (which bundles Node 22) are currently exposed.Change
When
resolveSrvrejects with a network-layer error code (ECONNREFUSED,ECONNRESET,ETIMEDOUT,ESERVFAIL,EREFUSED), retry once against a user-independent public resolver (1.1.1.1,8.8.8.8) using an explicitResolverinstance. Legitimate "no SRV record" responses (ENOTFOUND,ENODATA, etc.) still short-circuit tonull, so the extra lookup only happens when the system resolver is actually broken.A single
logger.warnline identifies the failing error code so launcher operators can tell whether the fallback kicked in.Reproduction before the patch
On a Windows host running Node 22.22.0:
Same host on Node 20.18.1 returns the correct SRV record and the real system DNS servers. With this patch,
checkSrvtransparently recovers on Node 22 by retrying through the public resolver, andgetServerStatushits the correct port.Test plan
npm run build— clean TypeScript compilenpm run lint— no new warningsServerStatusAPITest(real-network test) runs unchanged in working environments (fast path untouched)