Skip to content

Expose getDefaultResultOrder on node:dns/promises and fix its return value - #28949

Merged
dylan-conway merged 4 commits into
mainfrom
farm/bcfb980d/dns-get-default-result-order
Apr 7, 2026
Merged

dylan-conway merged 4 commits into
mainfrom
farm/bcfb980d/dns-get-default-result-order

Conversation

@robobun

@robobun robobun commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

Fixes #28948

Repro

import { promises } from "node:dns";
promises.getDefaultResultOrder();
// TypeError: promises.getDefaultResultOrder is not a function

This is exactly what Vite 8's DNS lookup helper does, and it breaks Vite 8 builds under Bun.

Cause

src/js/node/dns.ts had two related bugs:

  1. dns.getDefaultResultOrder() was implemented as return defaultResultOrder; — it returned the internal defaultResultOrder function object instead of invoking it. Node returns a string ("ipv4first" / "ipv6first" / "verbatim").
  2. The promises export was missing getDefaultResultOrder entirely, and was also missing getServers. Both exist on dns.promises (and therefore node:dns/promises) in Node.

Fix

 function getDefaultResultOrder() {
-  return defaultResultOrder;
+  return defaultResultOrder();
 }
 const promises = {
   …
+  getDefaultResultOrder,
   setDefaultResultOrder,
+  getServers,
   setServers,
 };

setDefaultResultOrder mutates module-level state, so dns, dns.promises, and node:dns/promises share the same order value — matching Node's behavior.

Verification

$ bun bd test test/regression/issue/28948.test.ts
 7 pass
 0 fail
 36 expect() calls

With the fix stashed, all 7 regression tests fail (returning "[Function: defaultResultOrder]" or undefined). Existing test/js/node/dns/node-dns.test.js suite still passes (66/66).

…value

- dns.getDefaultResultOrder() now returns the current order string
  ("ipv4first" | "ipv6first" | "verbatim") instead of the internal
  defaultResultOrder function object.
- Added getDefaultResultOrder and getServers to the dns.promises export
  (and therefore to node:dns/promises) to match Node.js.

Fixes #28948
@robobun

robobun commented Apr 7, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 5:21 PM PT - Apr 7th, 2026

❌ @dylan-conway, your commit d50597e has 2 failures in Build #44321 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 28949

That installs a local version of the PR into your bun-28949 executable, so you can run:

bun-28949 --bun

@github-actions github-actions Bot added the claude label Apr 7, 2026
@coderabbitai

coderabbitai Bot commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 892714ee-4e9d-4558-a718-cc697633dd72

📥 Commits

Reviewing files that changed from the base of the PR and between 28cff7d and 6f30aad.

📒 Files selected for processing (1)
  • test/regression/issue/28948.test.ts

Walkthrough

Exposed getDefaultResultOrder and getServers on dns.promises, changed getDefaultResultOrder() to return the computed value (defaultResultOrder()), and added regression tests validating getters, state propagation, and getServers across dns, dns.promises, and node:dns/promises.

Changes

Cohort / File(s) Summary
DNS API Implementation
src/js/node/dns.ts
Changed getDefaultResultOrder() to call and return defaultResultOrder(). Added promises.getDefaultResultOrder and promises.getServers to expose the same API surface on the promises namespace.
Regression Test
test/regression/issue/28948.test.ts
Added tests that spawn Bun subprocesses to verify getDefaultResultOrder exists and returns one of ipv4first/ipv6first/verbatim across dns, dns.promises, node:dns/promises, ensure setDefaultResultOrder state propagates, and confirm getServers is defined and returns arrays.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: exposing getDefaultResultOrder on node:dns/promises and fixing its return value to match Node.js behavior.
Description check ✅ Passed The description covers the issue, root cause, fix applied, and verification results. It follows the template with clear sections addressing what the PR does and how it was verified.
Linked Issues check ✅ Passed The PR fully addresses #28948 by: (1) exposing getDefaultResultOrder and getServers on promises object, (2) fixing getDefaultResultOrder to return the computed string value instead of the function reference, and (3) ensuring shared state between dns and dns.promises exports.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing #28948: src/js/node/dns.ts fixes the API gap, and test/regression/issue/28948.test.ts adds regression tests validating the fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/regression/issue/28948.test.ts`:
- Around line 2-8: The file header in test/regression/issue/28948.test.ts
contains extra prose about the bug; replace the multi-line comment block with a
single-line GitHub issue URL comment only (leave the one-line issue reference at
the top) and remove the explanatory sentences about node:dns/promises and
getDefaultResultOrder so that the test header contains only the canonical issue
link; move any remaining narrative into the PR/issue description rather than the
test source.
- Around line 15-29: The shared spawn helper run currently asserts exitCode
inside run, which prevents callers from seeing stdout diffs on failure; modify
the run function (the async run(src: string) that spawns Bun via Bun.spawn and
currently returns stdout) to stop asserting exitCode and instead return both
stdout and exitCode (or return [stdout, stderr, exitCode]) so each test can
perform its own assertions; specifically remove the line
expect(exitCode).toBe(0) from run and update callers/tests to assert
expect(stdout).toBe(...) before calling expect(exitCode).toBe(0).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 707f7420-3c5e-4e49-a096-39ffc57c6dc2

📥 Commits

Reviewing files that changed from the base of the PR and between 0ff0065 and 28cff7d.

📒 Files selected for processing (2)
  • src/js/node/dns.ts
  • test/regression/issue/28948.test.ts

Comment thread test/regression/issue/28948.test.ts Outdated
Comment thread test/regression/issue/28948.test.ts Outdated

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — simple one-liner fix for returning a function instead of a string, plus the missing exports on .

Extended reasoning...

Overview

The PR touches two files: (3 lines changed) and a new regression test file. The fix addresses two bugs: returned the internal function object instead of calling it, and the export was missing and entirely.

Security risks

None. This is a pure Node.js compatibility fix for DNS API surface. No auth, crypto, or permission logic is touched.

Level of scrutiny

Low. The changes are minimal and mechanical: → , and two property additions to an object literal. The correctness is self-evident and verified by the regression tests.

Other factors

The inline bug comments flag two test-quality nits (missing and assertion ordering in the helper). These are legitimate style issues per conventions but do not affect correctness. The underlying fix is sound.

Comment thread test/regression/issue/28948.test.ts
Comment thread test/regression/issue/28948.test.ts Outdated
@coderabbitai

coderabbitai Bot commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ No merge conflicts detected when merging into main.

Your branch is good to go!

1 similar comment
@coderabbitai

coderabbitai Bot commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ No merge conflicts detected when merging into main.

Your branch is good to go!

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — all previous feedback addressed, fix is correct and well-tested.

Extended reasoning...

Overview

Two-line fix in src/js/node/dns.ts: calls defaultResultOrder() instead of returning the function reference, and adds getDefaultResultOrder and getServers to the promises export object. A new regression test file covers all three export surfaces (dns, dns.promises, node:dns/promises) with 7 concurrent subprocess tests.

Security risks

None. This is a DNS API surface fix with no auth, crypto, or permission code involved.

Level of scrutiny

Low. The changes are mechanical and narrowly scoped. The bug was a classic "forgot to call the function" typo, and the missing properties on promises are additive. No logic changes, no behavioral changes beyond the fix.

Other factors

All three inline comments from my prior review (test.concurrent, assertion ordering, header cleanup) were addressed in commit 6f30aad. No bugs found by the automated system. The fix matches Node.js behavior as documented in the PR description.

@robobun

robobun commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator Author

CI failures on this build are unrelated flakes:

  • darwin-13-x64-test-bun — test/bake/dev-and-prod.test.ts (dev-server hot-reload SIGKILL). My test (test/regression/issue/28948.test.ts) passed 7/7 in 77ms on this lane.
  • ubuntu-25.04-aarch64-test-bun — fetch upgrade > should upgrade to websocket hit the 90s timeout. My test is not mentioned in this lane's log.

Neither failure touches node:dns or test/regression/issue/28948.test.ts. Both test files are known-flaky pre-existing and the fix itself is a 3-line JS-only change to src/js/node/dns.ts.

@robobun

robobun commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator Author

Updated investigation after more test lanes reported: all 12 failing lanes (alpine, debian, ubuntu, darwin-14 × arches) fail identically on Valkey Redis Client (tls) > Basic Operations tests with RedisError: Connection closed (~31s timeout per test). This is a Redis/TLS infrastructure problem, completely unrelated to a 3-line JS-only DNS fix in src/js/node/dns.ts. My regression test test/regression/issue/28948.test.ts passes on the lanes it lands on (e.g. darwin-13-x64: 7/7 in 77ms). No code fix warranted on this PR.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — all prior feedback addressed.

Extended reasoning...

Overview

A 3-line JS-only fix to src/js/node/dns.ts: corrects getDefaultResultOrder() to call the inner function rather than return it, and adds getDefaultResultOrder and getServers to the promises export. A 129-line regression test covers all three export paths and state-sharing behavior.

Security risks

None. This is a pure JavaScript module exposing existing DNS API surface — no auth, crypto, or permission-sensitive code paths involved.

Level of scrutiny

Low. The diff is minimal and mechanical: one missing () and two missing property references. The change mirrors Node.js behavior exactly and the fix is verifiable by reading the existing defaultResultOrder function definition.

Other factors

All feedback from my prior review was addressed in commit 6f30aad: test headers cleaned up, run() now returns {stdout, stderr, exitCode} with stdout asserted before exitCode in each test body, and all 7 tests converted to test.concurrent. CI failures are unrelated infrastructure flakes (Redis/TLS timeouts). The regression test passed 7/7 on the lanes it ran.

@robobun

robobun commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator Author

Gate re-ran on d50597e (merge from main) and flagged as failure. Investigation:

  • Local run with fix: 7/7 pass (bun bd test test/regression/issue/28948.test.ts → Ran 7 tests across 1 file. [5.19s])
  • Gate's "release without fix" lane correctly shows 7 failures using the cached system bun
  • Gate's "with fix" lanes report BUILD FAILED — all four build paths hit TLS cert failures fetching zig/WebKit from github (unable to verify the first certificate). Curl works; NODE_TLS_REJECT_UNAUTHORIZED=0 makes Bun's fetch work. The gate runner's environment is the issue, not the fix.

The fix itself is 3 lines in src/js/node/dns.ts and has been verified locally on the new merge base.

@robobun

robobun commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator Author

Build #44321 (on d50597e after main merge): 54 pass / 2 test-lane fails, both identical Valkey Redis Client (tls) > Basic Operations / RedisError: Connection closed 31s timeouts. Same pre-existing infrastructure flake documented in my earlier comments. My test is not on these shards. No code fix warranted.

@dylan-conway
dylan-conway merged commit c99fd9d into main Apr 7, 2026
53 of 62 checks passed
@dylan-conway
dylan-conway deleted the farm/bcfb980d/dns-get-default-result-order branch April 7, 2026 22:45
structwafel pushed a commit to structwafel/bun that referenced this pull request Apr 25, 2026
…value (oven-sh#28949)

Fixes oven-sh#28948

## Repro

```js
import { promises } from "node:dns";
promises.getDefaultResultOrder();
// TypeError: promises.getDefaultResultOrder is not a function
```

This is exactly what Vite 8's DNS lookup helper does, and it breaks Vite
8 builds under Bun.

## Cause

`src/js/node/dns.ts` had two related bugs:

1. `dns.getDefaultResultOrder()` was implemented as `return
defaultResultOrder;` — it returned the internal `defaultResultOrder`
**function object** instead of invoking it. Node returns a string
(`"ipv4first"` / `"ipv6first"` / `"verbatim"`).
2. The `promises` export was missing `getDefaultResultOrder` entirely,
and was also missing `getServers`. Both exist on `dns.promises` (and
therefore `node:dns/promises`) in Node.

## Fix

```diff
 function getDefaultResultOrder() {
-  return defaultResultOrder;
+  return defaultResultOrder();
 }
```

```diff
 const promises = {
   …
+  getDefaultResultOrder,
   setDefaultResultOrder,
+  getServers,
   setServers,
 };
```

`setDefaultResultOrder` mutates module-level state, so `dns`,
`dns.promises`, and `node:dns/promises` share the same order value —
matching Node's behavior.

## Verification

```
$ bun bd test test/regression/issue/28948.test.ts
 7 pass
 0 fail
 36 expect() calls
```

With the fix stashed, all 7 regression tests fail (returning
`"[Function: defaultResultOrder]"` or `undefined`). Existing
`test/js/node/dns/node-dns.test.js` suite still passes (66/66).

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
xhjkl pushed a commit to xhjkl/bun that referenced this pull request May 14, 2026
…value (oven-sh#28949)

Fixes oven-sh#28948

## Repro

```js
import { promises } from "node:dns";
promises.getDefaultResultOrder();
// TypeError: promises.getDefaultResultOrder is not a function
```

This is exactly what Vite 8's DNS lookup helper does, and it breaks Vite
8 builds under Bun.

## Cause

`src/js/node/dns.ts` had two related bugs:

1. `dns.getDefaultResultOrder()` was implemented as `return
defaultResultOrder;` — it returned the internal `defaultResultOrder`
**function object** instead of invoking it. Node returns a string
(`"ipv4first"` / `"ipv6first"` / `"verbatim"`).
2. The `promises` export was missing `getDefaultResultOrder` entirely,
and was also missing `getServers`. Both exist on `dns.promises` (and
therefore `node:dns/promises`) in Node.

## Fix

```diff
 function getDefaultResultOrder() {
-  return defaultResultOrder;
+  return defaultResultOrder();
 }
```

```diff
 const promises = {
   …
+  getDefaultResultOrder,
   setDefaultResultOrder,
+  getServers,
   setServers,
 };
```

`setDefaultResultOrder` mutates module-level state, so `dns`,
`dns.promises`, and `node:dns/promises` share the same order value —
matching Node's behavior.

## Verification

```
$ bun bd test test/regression/issue/28948.test.ts
 7 pass
 0 fail
 36 expect() calls
```

With the fix stashed, all 7 regression tests fail (returning
`"[Function: defaultResultOrder]"` or `undefined`). Existing
`test/js/node/dns/node-dns.test.js` suite still passes (66/66).

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node:dns/promises.getDefaultResultOrder is undefined in Bun (breaks Vite 8 build)

2 participants