-
Notifications
You must be signed in to change notification settings - Fork 5k
fix(node:dns): don't expose ARES errno on query errors (fixes #37320) #39620
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -609,6 +609,31 @@ describe("test invalid arguments", () => { | |
| await promise.catch(() => {}); // result depends on the environment's resolver | ||
| }); | ||
|
|
||
| // https://github.com/oven-sh/bun/issues/37320 | ||
| describe("DNS error errno matches Node.js", () => { | ||
| it("dns.promises.resolve errors have no errno", async () => { | ||
| const error = await dns_promises.resolveAny("invalid.invalid").catch(e => e); | ||
| expect(error.code).toBe("ENOTFOUND"); | ||
| expect(error.errno).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("dns.resolve callback errors have no errno", async () => { | ||
| const error = await new Promise(resolve => { | ||
| dns.resolveAny("invalid.invalid", (err, records) => resolve(err)); | ||
| }); | ||
| expect(error.code).toBe("ENOTFOUND"); | ||
| expect(error.errno).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("dns.lookup errors keep a numeric errno", async () => { | ||
| const error = await new Promise(resolve => { | ||
| dns.lookup("invalid.invalid", err => resolve(err)); | ||
| }); | ||
| expect(error.code).toBe("ENOTFOUND"); | ||
| expect(typeof error.errno).toBe("number"); | ||
| }); | ||
|
Comment on lines
+628
to
+634
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win Cover the The new branch preserves numeric As per coding guidelines: tests must cover the complete relevant variant matrix, including sibling APIs. 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| }); | ||
|
|
||
| it("dns.lookupService", async () => { | ||
| expect(() => { | ||
| dns.lookupService("", 443, (err, hostname, service) => {}); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Use a hermetic DNS fixture.
These tests query the configured DNS resolver for
invalid.invalid. Results and latency depend on network access and resolver configuration. Use an in-process DNS fixture or an existing local resolver harness for deterministic c-ares andgetaddrinfoerrors.As per coding guidelines: tests must be hermetic and avoid external services.
Also applies to: 629-631
🤖 Prompt for AI Agents
Source: Coding guidelines