fix(ide): add async DNS check for host.docker.internal in container environments#1817
Open
yiliang114 wants to merge 1 commit intoQwenLM:mainfrom
Open
fix(ide): add async DNS check for host.docker.internal in container environments#1817yiliang114 wants to merge 1 commit intoQwenLM:mainfrom
yiliang114 wants to merge 1 commit intoQwenLM:mainfrom
Conversation
…nvironments In container environments like code-server where host.docker.internal may not be configured, the IDE client would fail to connect. This change makes getIdeServerHost() async and adds a DNS lookup to verify the hostname is actually resolvable before using it, falling back to 127.0.0.1 if not. Co-authored-by: Cursor <[email protected]>
Contributor
📋 Review SummaryThis PR addresses an important issue where the IDE client connection fails in container environments where 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
pomelo-nwu
approved these changes
Feb 13, 2026
| */ | ||
| function checkHostReachable(hostname: string): Promise<boolean> { | ||
| return new Promise((resolve) => { | ||
| dns.lookup(hostname, (err) => { |
Collaborator
There was a problem hiding this comment.
dns.lookup has no timeout — under poor network conditions it could block for tens of seconds. Consider wrapping it with a ~3s setTimeout fallback to keep the connection flow snappy.
Rest looks great, solid test coverage 👍
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.
TLDR
Fix IDE client connection failure in container environments (e.g. code-server / WebIDE) where
host.docker.internalis not available. ThegetIdeServerHost()function is now async and performs a DNS lookup to verifyhost.docker.internalis resolvable before using it, automatically falling back to127.0.0.1when it is not.Dive Deeper
Problem
In Docker Desktop,
host.docker.internalis automatically configured to resolve to the host machine. However, this hostname may not exist in:--add-host=host.docker.internal:host-gatewayThe previous implementation detected container environments via
/.dockerenvor/run/.containerenvand unconditionally usedhost.docker.internal, causing IDE connection failures in environments where that hostname is unresolvable.Changes
getIdeServerHost(): Now performs adns.lookupto check ifhost.docker.internalis resolvable before using it_resetCachedIdeServerHost()for test isolationReviewer Test Plan
npx vitest run packages/core/src/ide/ide-client.test.tshost.docker.internalconfigured, verify IDE connects normallyhost.docker.internal, verify IDE falls back to127.0.0.1Testing Matrix
Linked issues / bugs
Fixes #1567