Skip to content

fix(network): respect macOS scoped DNS - #12934

Merged
zkochan merged 2 commits into
pnpm:mainfrom
sensei-woo:codex/fix-macos-scoped-dns
Jul 13, 2026
Merged

zkochan merged 2 commits into
pnpm:mainfrom
sensei-woo:codex/fix-macos-scoped-dns

Conversation

@sensei-woo

@sensei-woo sensei-woo commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

pnpm v12 hard-enables Hickory DNS for install requests. On macOS, Hickory reads the global DNS state but does not honor the full scoped/supplemental resolver graph used by VPNs such as Tailscale. In that setup, public registry names can be sent to a supplemental resolver with its search suffix and repeatedly fail.

Fix

  • use macOS native getaddrinfo resolution through tokio::net::lookup_host
  • cap native lookups at four concurrent requests, matching Node/libuv behavior and retaining protection against mDNSResponder overload
  • keep Hickory on non-macOS platforms
  • cover the concurrency cap with a deterministic resolver test

This also avoids a registry-specific trailing-dot workaround, so tarball, custom-registry, and other HTTP hosts use the same correct macOS resolver routing. Hickory per-domain macOS resolver support is tracked in hickory-dns/hickory-dns#2251.

Verification

  • cargo fmt --all -- --check
  • cargo test -p pacquet-network (102 passed)
  • cargo clippy -p pacquet-network --tests --no-deps
  • fresh CLI install from https://registry.npmjs.org/ on the affected Tailscale Mac (2 packages downloaded, 271 ms)

Summary by CodeRabbit

  • Bug Fixes
    • Improved DNS resolution during installs on macOS by switching to native DNS behavior to respect scoped and VPN-provided resolvers.
    • Added a bounded concurrency limit for DNS lookups (max 4 simultaneous resolutions) to improve reliability and avoid resource exhaustion.
    • Kept existing DNS behavior on non-macOS platforms.
  • Tests
    • Added coverage to verify the DNS resolver enforces the concurrency cap and completes all lookups correctly.
  • Chores
    • Released as a patch update.

@sensei-woo
sensei-woo requested a review from zkochan as a code owner July 11, 2026 07:04
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@welcome

welcome Bot commented Jul 11, 2026

Copy link
Copy Markdown

💖 Thanks for opening this pull request! 💖
Please be patient and we will get back to you as soon as we can.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@zkochan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cb2c2d05-4e1c-4507-8ec1-bbce2aa1b545

📥 Commits

Reviewing files that changed from the base of the PR and between 38b4db6 and 6e85b10.

📒 Files selected for processing (3)
  • .changeset/calm-cats-resolve.md
  • pnpm/crates/network/src/lib.rs
  • pnpm/crates/network/src/tests.rs
📝 Walkthrough

Walkthrough

The network client now uses macOS native DNS resolution with bounded concurrency, retains Hickory DNS on other platforms, and adds tests verifying the concurrency limit. A patch changeset documents the release.

Changes

DNS resolution behavior

Layer / File(s) Summary
Resolver implementation and client wiring
pnpm/crates/network/src/lib.rs, .changeset/calm-cats-resolve.md
Adds native and semaphore-capped DNS resolvers for macOS/tests, updates documentation, routes the default client builder through platform-specific configuration, and records a patch release.
Concurrency-cap validation
pnpm/crates/network/src/tests.rs
Adds a recording resolver and verifies that four DNS resolutions run concurrently while additional tasks wait and all tasks complete.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ClientBuilder
  participant CappedDnsResolver
  participant NativeDnsResolver
  participant lookup_host
  ClientBuilder->>CappedDnsResolver: Configure DNS on macOS/tests
  CappedDnsResolver->>NativeDnsResolver: Acquire permit and resolve
  NativeDnsResolver->>lookup_host: Perform native hostname lookup
  lookup_host-->>NativeDnsResolver: Return addresses
  NativeDnsResolver-->>CappedDnsResolver: Return resolved addresses
  CappedDnsResolver-->>ClientBuilder: Provide capped resolver
Loading

Suggested labels: product: pacquet

Suggested reviewers: zkochan, qodo-code-review

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 11, 2026
@codecov-commenter

codecov-commenter commented Jul 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.42%. Comparing base (d3e1383) to head (6d7a51f).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12934      +/-   ##
==========================================
+ Coverage   85.26%   85.42%   +0.16%     
==========================================
  Files         486      489       +3     
  Lines       77280    77836     +556     
==========================================
+ Hits        65890    66491     +601     
+ Misses      11390    11345      -45     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 38b4db616dca

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.818 ± 0.631 4.104 5.995 1.91 ± 0.37
pacquet@main 4.107 ± 0.195 3.929 4.466 1.63 ± 0.25
pnpr@HEAD 2.758 ± 0.455 2.157 3.731 1.10 ± 0.24
pnpr@main 2.516 ± 0.363 2.126 3.222 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.81752192654,
      "stddev": 0.6307583652336342,
      "median": 4.77103499014,
      "user": 3.6553750000000003,
      "system": 2.03395028,
      "min": 4.1037405831400005,
      "max": 5.99453059814,
      "times": [
        4.98906349614,
        5.99453059814,
        5.01775843114,
        5.02313947914,
        5.61708843314,
        4.20084785014,
        4.44908431014,
        4.1037405831400005,
        4.22695960014,
        4.55300648414
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.10706969164,
      "stddev": 0.1946450392398457,
      "median": 4.00578098714,
      "user": 3.7140690999999997,
      "system": 2.05099438,
      "min": 3.9288414621400003,
      "max": 4.4661354621400005,
      "times": [
        4.4661354621400005,
        4.38401583714,
        4.15572907314,
        3.9288414621400003,
        4.23736662514,
        3.9673321341400003,
        4.01875458914,
        3.97594180914,
        3.99280738514,
        3.9437725391400003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.75822748024,
      "stddev": 0.45500028654686336,
      "median": 2.65740310964,
      "user": 2.5152995999999996,
      "system": 1.68849678,
      "min": 2.15711419414,
      "max": 3.73112672314,
      "times": [
        2.50917493714,
        2.15711419414,
        3.19361005214,
        2.34095608814,
        2.60144971914,
        2.72222887114,
        2.71335650014,
        2.58630784114,
        3.73112672314,
        3.02694987614
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.5162612216400007,
      "stddev": 0.363401371936826,
      "median": 2.48576181664,
      "user": 2.5329874,
      "system": 1.7063699799999998,
      "min": 2.12638282014,
      "max": 3.22168694814,
      "times": [
        3.22168694814,
        2.49899829814,
        2.24526288414,
        2.72039657614,
        2.98262356514,
        2.49447044814,
        2.17285315814,
        2.12638282014,
        2.47705318514,
        2.22288433314
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 651.8 ± 87.8 564.7 759.4 1.05 ± 0.19
pacquet@main 622.3 ± 72.9 556.3 746.5 1.00
pnpr@HEAD 798.4 ± 245.7 568.1 1399.9 1.28 ± 0.42
pnpr@main 737.1 ± 103.7 606.9 956.6 1.18 ± 0.22
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6518072285000001,
      "stddev": 0.08784701529690328,
      "median": 0.6366453076,
      "user": 0.36744432000000005,
      "system": 0.7371167,
      "min": 0.5646767921,
      "max": 0.7594053391000001,
      "times": [
        0.5751816461,
        0.6981089691000001,
        0.7519251451000001,
        0.5646767921,
        0.5723767731,
        0.7370201001000001,
        0.7217682791000001,
        0.5677939121000001,
        0.5698153291,
        0.7594053391000001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.622267483,
      "stddev": 0.0729171805356289,
      "median": 0.5899349401,
      "user": 0.35587161999999994,
      "system": 0.7228085000000001,
      "min": 0.5563413551,
      "max": 0.7464592741,
      "times": [
        0.7079139871000001,
        0.5598816391,
        0.6883482551000001,
        0.6032056321,
        0.5563413551,
        0.5594646941,
        0.5766642481,
        0.7464592741,
        0.6665044211000001,
        0.5578913241000001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7983850321,
      "stddev": 0.24568259951004878,
      "median": 0.7214690796000001,
      "user": 0.37603131999999995,
      "system": 0.7256818,
      "min": 0.5681387491000001,
      "max": 1.3998527671,
      "times": [
        0.6243930141,
        0.7257531821000001,
        0.5681387491000001,
        0.5954738001000001,
        0.6679143591000001,
        0.7171849771000001,
        1.3998527671,
        0.8978168911000001,
        0.9001120001,
        0.8872105811000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7371390110999999,
      "stddev": 0.10366832199847693,
      "median": 0.7243422181000001,
      "user": 0.37601312,
      "system": 0.7437674000000001,
      "min": 0.6068574621,
      "max": 0.9565863631000001,
      "times": [
        0.6139569671,
        0.9565863631000001,
        0.8592032561,
        0.7277899951000001,
        0.6068574621,
        0.7208944411,
        0.7118500641000001,
        0.7278943401000001,
        0.7179776391,
        0.7283795831000001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.651 ± 0.332 4.227 5.321 1.84 ± 0.28
pacquet@main 4.639 ± 0.197 4.306 4.819 1.83 ± 0.25
pnpr@HEAD 2.530 ± 0.334 2.173 3.375 1.00
pnpr@main 2.612 ± 0.371 2.071 3.469 1.03 ± 0.20
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.65093166328,
      "stddev": 0.3323630813320614,
      "median": 4.543575822879999,
      "user": 3.66727944,
      "system": 1.95408068,
      "min": 4.22687270188,
      "max": 5.32135594788,
      "times": [
        4.51907577388,
        5.32135594788,
        4.22687270188,
        5.13528434688,
        4.37718771688,
        4.63517310988,
        4.55129491488,
        4.5326294558799995,
        4.6745859338799995,
        4.53585673088
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.638903260579999,
      "stddev": 0.19745618779815774,
      "median": 4.72245822788,
      "user": 3.6598538399999994,
      "system": 1.9590062799999994,
      "min": 4.30609015588,
      "max": 4.81872279788,
      "times": [
        4.8111925828799995,
        4.59697302488,
        4.33760739888,
        4.78785459788,
        4.70677273988,
        4.73814371588,
        4.48646078588,
        4.81872279788,
        4.79921480588,
        4.30609015588
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.52953598488,
      "stddev": 0.33413038583161714,
      "median": 2.49393160038,
      "user": 2.3026057399999997,
      "system": 1.6306178799999997,
      "min": 2.17292300588,
      "max": 3.37459108788,
      "times": [
        2.22034324788,
        2.3647079028799998,
        2.51233800688,
        2.61290671188,
        2.57049356288,
        2.61110554788,
        2.38042558088,
        2.47552519388,
        3.37459108788,
        2.17292300588
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.61247724748,
      "stddev": 0.3711395191471553,
      "median": 2.53758706088,
      "user": 2.28317954,
      "system": 1.6065210799999996,
      "min": 2.07111103488,
      "max": 3.46937071888,
      "times": [
        2.41484494988,
        2.72092304788,
        2.71785261688,
        2.45646775588,
        2.47083588888,
        2.3696983878799998,
        2.07111103488,
        2.60433823288,
        3.46937071888,
        2.82932984088
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.251 ± 0.049 1.204 1.354 1.93 ± 0.37
pacquet@main 1.369 ± 0.218 1.212 1.871 2.11 ± 0.52
pnpr@HEAD 0.648 ± 0.120 0.581 0.979 1.00
pnpr@main 0.653 ± 0.047 0.590 0.745 1.01 ± 0.20
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.2507981939600001,
      "stddev": 0.0486373315073732,
      "median": 1.2397833385600001,
      "user": 1.2679281599999999,
      "system": 0.92642358,
      "min": 1.20402943156,
      "max": 1.35427736356,
      "times": [
        1.23638540756,
        1.24318126956,
        1.22100571756,
        1.20756792156,
        1.35427736356,
        1.25916947556,
        1.2130657385599999,
        1.31282054056,
        1.25647907356,
        1.20402943156
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.36854553056,
      "stddev": 0.21789377272568866,
      "median": 1.2691895290600002,
      "user": 1.28163886,
      "system": 0.93976118,
      "min": 1.21228019456,
      "max": 1.87059173056,
      "times": [
        1.29186968756,
        1.23902769856,
        1.25262679156,
        1.65261949556,
        1.87059173056,
        1.37686081156,
        1.21228019456,
        1.2843290895600001,
        1.25404996856,
        1.25119983756
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6477814876600001,
      "stddev": 0.12028953667256478,
      "median": 0.60204511356,
      "user": 0.31910466,
      "system": 0.6866764799999998,
      "min": 0.58061582156,
      "max": 0.9793770645600001,
      "times": [
        0.59286702256,
        0.59286675556,
        0.58061582156,
        0.5957059395600001,
        0.6083842875600001,
        0.5884506645600001,
        0.68170150456,
        0.62251721356,
        0.63532860256,
        0.9793770645600001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6533891159600002,
      "stddev": 0.047185626214910396,
      "median": 0.64686923656,
      "user": 0.31600755999999997,
      "system": 0.69001178,
      "min": 0.59013679456,
      "max": 0.74489191956,
      "times": [
        0.60372699956,
        0.59013679456,
        0.65284705156,
        0.68563721556,
        0.74489191956,
        0.6335447375600001,
        0.65251788956,
        0.64122058356,
        0.62369379356,
        0.70567417456
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.971 ± 0.163 2.836 3.360 4.87 ± 0.31
pacquet@main 2.965 ± 0.139 2.872 3.350 4.86 ± 0.28
pnpr@HEAD 0.610 ± 0.020 0.585 0.649 1.00
pnpr@main 0.612 ± 0.039 0.581 0.712 1.00 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.97090305532,
      "stddev": 0.16313980652951734,
      "median": 2.91297482572,
      "user": 1.7879826,
      "system": 1.1353429,
      "min": 2.83632165872,
      "max": 3.36023829272,
      "times": [
        2.83632165872,
        2.98597829872,
        2.90959518572,
        2.8872983757200004,
        2.91635446572,
        3.14873358072,
        2.93704332272,
        2.85520856572,
        3.36023829272,
        2.87225880672
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.9645315971199997,
      "stddev": 0.13906706356147408,
      "median": 2.92935213972,
      "user": 1.7750622,
      "system": 1.1554638000000002,
      "min": 2.8721238697200002,
      "max": 3.34978859772,
      "times": [
        2.93112821272,
        2.95309851272,
        2.89580765472,
        2.8721238697200002,
        2.9275760667200004,
        2.95278541472,
        2.89763181172,
        2.8932043637200002,
        3.34978859772,
        2.97217146672
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.60959606262,
      "stddev": 0.02003346425451122,
      "median": 0.60463679072,
      "user": 0.32280889999999995,
      "system": 0.6915538999999999,
      "min": 0.58540668172,
      "max": 0.64930001672,
      "times": [
        0.58540668172,
        0.63726073972,
        0.6047260087199999,
        0.59700342872,
        0.60454757272,
        0.64930001672,
        0.61474632872,
        0.59981912572,
        0.5909302547199999,
        0.61222046872
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6122519775199999,
      "stddev": 0.0389665096551999,
      "median": 0.59762850122,
      "user": 0.32231319999999997,
      "system": 0.6918151,
      "min": 0.5810460857199999,
      "max": 0.71157200372,
      "times": [
        0.59592512672,
        0.62205551072,
        0.5810460857199999,
        0.71157200372,
        0.63750413572,
        0.60592222272,
        0.5970126367199999,
        0.59824436572,
        0.58191532472,
        0.5913223627199999
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 614.4 ± 9.5 605.0 629.6 6.15 ± 0.12
pacquet@main 609.4 ± 7.2 597.5 622.5 6.10 ± 0.10
pnpr@HEAD 99.9 ± 1.2 96.9 101.8 1.00
pnpr@main 99.9 ± 0.9 96.5 100.9 1.00 ± 0.01
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.61437375358,
      "stddev": 0.009474607840713129,
      "median": 0.6116446842800001,
      "user": 0.59519906,
      "system": 0.10152846,
      "min": 0.6049663657800001,
      "max": 0.6295873107800001,
      "times": [
        0.6059938677800001,
        0.6295873107800001,
        0.6049663657800001,
        0.60593774978,
        0.60904158178,
        0.61424778678,
        0.61689921778,
        0.62245553678,
        0.6280105837800001,
        0.60659753478
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.60941928148,
      "stddev": 0.007229372973632884,
      "median": 0.6095027337800001,
      "user": 0.59494116,
      "system": 0.09782055999999999,
      "min": 0.59751163178,
      "max": 0.6225212357800001,
      "times": [
        0.60107855678,
        0.6225212357800001,
        0.61254872378,
        0.6092340767800001,
        0.61702695878,
        0.59751163178,
        0.6064342247800001,
        0.60676187778,
        0.60977139078,
        0.61130413778
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09988945360142856,
      "stddev": 0.0011668153493998585,
      "median": 0.09994850528,
      "user": 0.024393945714285718,
      "system": 0.012840974285714285,
      "min": 0.09688699678,
      "max": 0.10181971878,
      "times": [
        0.09969253378,
        0.10116588378000001,
        0.09856408378,
        0.10011747078,
        0.10061265778,
        0.10044318778,
        0.09947471278,
        0.10095068278,
        0.09919958778,
        0.09951183378,
        0.10126394178,
        0.10132166878,
        0.09839821878,
        0.10020512078,
        0.09964484678,
        0.10042167278,
        0.10049689978,
        0.09992651278,
        0.09961094778,
        0.09943903078,
        0.09688699678,
        0.09997049778,
        0.10181971878,
        0.09754154578,
        0.10145660778,
        0.09941247678,
        0.10073727378,
        0.09861808778
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.09989132628,
      "stddev": 0.0008747212216001135,
      "median": 0.10004018328,
      "user": 0.02429215999999999,
      "system": 0.012954117142857142,
      "min": 0.09647503978,
      "max": 0.10091718078,
      "times": [
        0.09939129578,
        0.10070241378,
        0.09990878578,
        0.09995251478,
        0.09951012878,
        0.10030596878,
        0.10062902278,
        0.09929396978,
        0.10079252178,
        0.09971441978,
        0.10044302078,
        0.10091718078,
        0.10035867078,
        0.09906956578,
        0.09966464278,
        0.10041464078,
        0.09920544978,
        0.10052298278,
        0.09901473478,
        0.09647503978,
        0.10084550378,
        0.10014333878,
        0.09981868478,
        0.10012785178,
        0.10032975878,
        0.09960779178,
        0.10039490578,
        0.09940232978
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 15.008 ± 3.361 11.465 23.203 2.01 ± 0.67
pacquet@main 11.167 ± 3.179 8.077 18.888 1.49 ± 0.56
pnpr@HEAD 7.484 ± 1.204 5.667 8.616 1.00 ± 0.29
pnpr@main 7.475 ± 1.827 5.564 10.250 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 15.007503014,
      "stddev": 3.36094276818738,
      "median": 14.2019070714,
      "user": 3.66449656,
      "system": 2.14048814,
      "min": 11.4647346284,
      "max": 23.2027202624,
      "times": [
        16.8260410104,
        13.7350330574,
        16.3315714384,
        14.0745270984,
        14.329287044400001,
        12.746615611400001,
        11.4647346284,
        12.0518218804,
        15.3126781084,
        23.2027202624
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 11.1666478114,
      "stddev": 3.1785079739011257,
      "median": 10.473221436900001,
      "user": 3.65106846,
      "system": 2.1226609400000003,
      "min": 8.0771949804,
      "max": 18.887723956400002,
      "times": [
        18.887723956400002,
        12.6180251434,
        13.3045231954,
        10.7859576774,
        8.9059209214,
        8.0771949804,
        10.2701253344,
        9.0543365234,
        10.676317539400001,
        9.0863528424
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 7.483928744900001,
      "stddev": 1.2037660362317046,
      "median": 8.0483938044,
      "user": 2.51921736,
      "system": 1.7865895399999996,
      "min": 5.667415918400001,
      "max": 8.616413918400001,
      "times": [
        8.4187358614,
        5.9631755034000005,
        8.406336123400001,
        7.7562763684,
        8.616413918400001,
        8.3405112404,
        5.667415918400001,
        8.4938674064,
        5.8848653834,
        7.2916897254
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 7.474522939300002,
      "stddev": 1.826760548867035,
      "median": 6.6400808929,
      "user": 2.50308246,
      "system": 1.76688164,
      "min": 5.564451286400001,
      "max": 10.2500092324,
      "times": [
        5.7136595984000005,
        7.860556534400001,
        6.133465264400001,
        6.9279587494,
        6.352203036400001,
        5.564451286400001,
        6.346090822400001,
        9.8210784704,
        9.7757563984,
        10.2500092324
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12934
Testbedpacquet

🚨 1 Alert

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnprLatency
seconds (s)
📈 plot
🚷 threshold
🚨 alert (🔔)
15.01 s
(+104.07%)Baseline: 7.35 s
8.82 s
(170.06%)

Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,650.93 ms
(+8.37%)Baseline: 4,291.72 ms
5,150.06 ms
(90.31%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
2,970.90 ms
(-1.65%)Baseline: 3,020.75 ms
3,624.90 ms
(81.96%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,250.80 ms
(-7.97%)Baseline: 1,359.12 ms
1,630.95 ms
(76.69%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
614.37 ms
(-3.88%)Baseline: 639.21 ms
767.05 ms
(80.10%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,817.52 ms
(+16.39%)Baseline: 4,138.96 ms
4,966.75 ms
(97.00%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
🚨 view alert (🔔)
15,007.50 ms
(+104.07%)Baseline: 7,354.09 ms
8,824.91 ms
(170.06%)

isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
651.81 ms
(+0.33%)Baseline: 649.67 ms
779.60 ms
(83.61%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12934
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,169.24 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
650.79 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
675.85 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
108.06 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,197.11 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
5,005.76 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
732.76 ms
🐰 View full continuous benchmarking report in Bencher

@sensei-woo
sensei-woo force-pushed the codex/fix-macos-scoped-dns branch from fc585eb to 38b4db6 Compare July 11, 2026 10:48
@greptile-apps

greptile-apps Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge. The change is narrowly scoped to DNS resolver selection, macOS-only in production, and backed by a deterministic concurrency test.

The native-resolver path on macOS is straightforward: tokio::net::lookup_host delegates to the OS, the CappedDnsResolver wrapper is simple and correct, and the permit is held across the full lookup duration so the cap is never bypassed. The active.fetch_sub in the inner resolver happens synchronously before the outer permit drops, preserving the invariant across all scheduler orderings. Non-macOS behavior is unchanged. No regressions are plausible outside the macOS DNS path.

No files require special attention.

Reviews (3): Last reviewed commit: "fix(network): target pacquet in the scop..." | Re-trigger Greptile

@zkochan
zkochan force-pushed the codex/fix-macos-scoped-dns branch from 38b4db6 to 6d7a51f Compare July 13, 2026 13:11
@qodo-code-review

qodo-code-review Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (1) 📎 Requirement gaps (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. pnpm missing changeset entry 📘 Rule violation § Compliance ⭐ New
Description
The new changeset declares a bump for pacquet but does not include the required pnpm entry. This
violates the changeset policy and can prevent pnpm from being versioned/released correctly for
this fix.
Code

.changeset/calm-cats-resolve.md[2]

+"pacquet": patch
Evidence
Rule 713436 requires changeset front-matter to include a pnpm entry with a valid bump type. The
added changeset front-matter currently lists only "pacquet": patch, with no pnpm entry.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/calm-cats-resolve.md[1-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset front-matter is missing a required `pnpm` entry.

## Issue Context
Compliance requires every changeset to explicitly declare a `pnpm` bump (`patch`/`minor`/`major`) when relevant.

## Fix Focus Areas
- .changeset/calm-cats-resolve.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. DNS cap not global 🐞 Bug ➹ Performance
Description
On macOS, the 4-request DNS semaphore is created inside each CappedDnsResolver, and
configure_dns instantiates a new resolver for every reqwest::Client. Since
ThrottledClient::for_installs_with_redirect builds a default client plus one client per
per-registry override, total concurrent native lookups can exceed 4 and still overwhelm
mDNSResponder under multi-registry configs.
Code

pnpm/crates/network/src/lib.rs[R592-620]

+#[cfg(any(target_os = "macos", test))]
+impl<Inner> CappedDnsResolver<Inner> {
+    fn new(inner: Inner, concurrency: NonZeroUsize) -> Self {
+        Self { inner: Arc::new(inner), permits: Arc::new(Semaphore::new(concurrency.get())) }
+    }
+}
+
+#[cfg(any(target_os = "macos", test))]
+impl<Inner> Resolve for CappedDnsResolver<Inner>
+where
+    Inner: Resolve + 'static,
+{
+    fn resolve(&self, name: Name) -> Resolving {
+        let inner = Arc::clone(&self.inner);
+        let permits = Arc::clone(&self.permits);
+        Box::pin(async move {
+            let _permit =
+                permits.acquire_owned().await.expect("DNS concurrency semaphore is never closed");
+            inner.resolve(name).await
+        })
+    }
+}
+
+#[cfg(target_os = "macos")]
+fn configure_dns(builder: reqwest::ClientBuilder) -> reqwest::ClientBuilder {
+    const DNS_CONCURRENCY: NonZeroUsize = NonZeroUsize::new(4).expect("four is non-zero");
+
+    builder.dns_resolver(CappedDnsResolver::new(NativeDnsResolver, DNS_CONCURRENCY))
+}
Evidence
CappedDnsResolver::new allocates a fresh Semaphore, and configure_dns creates a new resolver
per ClientBuilder. Separately, for_installs_with_redirect builds one default client plus
additional clients for each per-registry override, meaning multiple independent DNS semaphores can
exist and allow >4 concurrent lookups in aggregate.

pnpm/crates/network/src/lib.rs[570-625]
pnpm/crates/network/src/lib.rs[383-432]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The macOS DNS concurrency cap is currently scoped to a single `reqwest::Client` because each `CappedDnsResolver::new(...)` allocates its own `Semaphore`. `ThrottledClient::for_installs_with_redirect` can create multiple clients (per-registry TLS overrides), allowing >4 concurrent native lookups across the process.

## Issue Context
The PR intent is to match Node/libuv’s global DNS thread pool behavior (4 concurrent `getaddrinfo` calls) and avoid `mDNSResponder` overload. The cap needs to be process-wide (or at least shared across all clients built by `ThrottledClient`).

## Fix Focus Areas
- pnpm/crates/network/src/lib.rs[570-625]
- pnpm/crates/network/src/lib.rs[383-432]

## Suggested approach
- Introduce a shared `Arc<Semaphore>` for macOS DNS lookups (e.g., `static DNS_PERMITS: OnceLock<Arc<Semaphore>>` or `LazyLock`).
- Change `CappedDnsResolver` construction to accept an `Arc<Semaphore>` (or add `CappedDnsResolver::with_permits(inner, permits)`), so every reqwest client uses the same semaphore.
- Keep the unit test using its own semaphore (so it stays deterministic) by constructing `CappedDnsResolver` with a test-local permits instance.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

3. DNS cap test may flake 🐞 Bug ☼ Reliability
Description
The new concurrency-cap test waits for 4 active resolutions using a 1s wall-clock timeout and a
yield-spin loop, which can fail under slow/loaded CI scheduling even if the implementation is
correct. This can make the test suite non-deterministic.
Code

pnpm/crates/network/src/tests.rs[R82-89]

+    tokio::time::timeout(Duration::from_secs(1), async {
+        while active.load(Ordering::SeqCst) < 4 {
+            tokio::task::yield_now().await;
+        }
+    })
+    .await
+    .expect("four resolutions should start");
+    assert_eq!(maximum_active.load(Ordering::SeqCst), 4);
Evidence
The test uses a tight (1s) timeout and depends on scheduler progress of spawned tasks to increment
active; if the executor is delayed, the timeout can fire even though the resolver is functioning
correctly.

pnpm/crates/network/src/tests.rs[57-97]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The test `capped_dns_resolver_limits_concurrency` relies on `timeout(Duration::from_secs(1))` plus polling (`yield_now`) to observe that 4 resolver calls started. Under heavy load, the spawned tasks might not all get scheduled within 1 second, causing a spurious failure.

## Issue Context
This only affects test reliability, but it can create intermittent CI failures.

## Fix Focus Areas
- pnpm/crates/network/src/tests.rs[57-97]

## Suggested approach
- Replace the polling+timeout with deterministic synchronization:
 - Add a `tokio::sync::Notify` or `Barrier` that the `RecordingResolver` signals when `active_count` reaches 4.
 - Await that notification (optionally with a more generous timeout as a backstop).
- Alternatively, increase the timeout substantially (e.g. 5–10s) to reduce flake probability, but prefer a notify/barrier for determinism.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 6e85b10

Results up to commit 6d7a51f


🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. DNS cap not global 🐞 Bug ➹ Performance
Description
On macOS, the 4-request DNS semaphore is created inside each CappedDnsResolver, and
configure_dns instantiates a new resolver for every reqwest::Client. Since
ThrottledClient::for_installs_with_redirect builds a default client plus one client per
per-registry override, total concurrent native lookups can exceed 4 and still overwhelm
mDNSResponder under multi-registry configs.
Code

pnpm/crates/network/src/lib.rs[R592-620]

+#[cfg(any(target_os = "macos", test))]
+impl<Inner> CappedDnsResolver<Inner> {
+    fn new(inner: Inner, concurrency: NonZeroUsize) -> Self {
+        Self { inner: Arc::new(inner), permits: Arc::new(Semaphore::new(concurrency.get())) }
+    }
+}
+
+#[cfg(any(target_os = "macos", test))]
+impl<Inner> Resolve for CappedDnsResolver<Inner>
+where
+    Inner: Resolve + 'static,
+{
+    fn resolve(&self, name: Name) -> Resolving {
+        let inner = Arc::clone(&self.inner);
+        let permits = Arc::clone(&self.permits);
+        Box::pin(async move {
+            let _permit =
+                permits.acquire_owned().await.expect("DNS concurrency semaphore is never closed");
+            inner.resolve(name).await
+        })
+    }
+}
+
+#[cfg(target_os = "macos")]
+fn configure_dns(builder: reqwest::ClientBuilder) -> reqwest::ClientBuilder {
+    const DNS_CONCURRENCY: NonZeroUsize = NonZeroUsize::new(4).expect("four is non-zero");
+
+    builder.dns_resolver(CappedDnsResolver::new(NativeDnsResolver, DNS_CONCURRENCY))
+}
Evidence
CappedDnsResolver::new allocates a fresh Semaphore, and configure_dns creates a new resolver
per ClientBuilder. Separately, for_installs_with_redirect builds one default client plus
additional clients for each per-registry override, meaning multiple independent DNS semaphores can
exist and allow >4 concurrent lookups in aggregate.

pnpm/crates/network/src/lib.rs[570-625]
pnpm/crates/network/src/lib.rs[383-432]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The macOS DNS concurrency cap is currently scoped to a single `reqwest::Client` because each `CappedDnsResolver::new(...)` allocates its own `Semaphore`. `ThrottledClient::for_installs_with_redirect` can create multiple clients (per-registry TLS overrides), allowing >4 concurrent native lookups across the process.

## Issue Context
The PR intent is to match Node/libuv’s global DNS thread pool behavior (4 concurrent `getaddrinfo` calls) and avoid `mDNSResponder` overload. The cap needs to be process-wide (or at least shared across all clients built by `ThrottledClient`).

## Fix Focus Areas
- pnpm/crates/network/src/lib.rs[570-625]
- pnpm/crates/network/src/lib.rs[383-432]

## Suggested approach
- Introduce a shared `Arc<Semaphore>` for macOS DNS lookups (e.g., `static DNS_PERMITS: OnceLock<Arc<Semaphore>>` or `LazyLock`).
- Change `CappedDnsResolver` construction to accept an `Arc<Semaphore>` (or add `CappedDnsResolver::with_permits(inner, permits)`), so every reqwest client uses the same semaphore.
- Keep the unit test using its own semaphore (so it stays deterministic) by constructing `CappedDnsResolver` with a test-local permits instance.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational
2. DNS cap test may flake 🐞 Bug ☼ Reliability
Description
The new concurrency-cap test waits for 4 active resolutions using a 1s wall-clock timeout and a
yield-spin loop, which can fail under slow/loaded CI scheduling even if the implementation is
correct. This can make the test suite non-deterministic.
Code

pnpm/crates/network/src/tests.rs[R82-89]

+    tokio::time::timeout(Duration::from_secs(1), async {
+        while active.load(Ordering::SeqCst) < 4 {
+            tokio::task::yield_now().await;
+        }
+    })
+    .await
+    .expect("four resolutions should start");
+    assert_eq!(maximum_active.load(Ordering::SeqCst), 4);
Evidence
The test uses a tight (1s) timeout and depends on scheduler progress of spawned tasks to increment
active; if the executor is delayed, the timeout can fire even though the resolver is functioning
correctly.

pnpm/crates/network/src/tests.rs[57-97]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The test `capped_dns_resolver_limits_concurrency` relies on `timeout(Duration::from_secs(1))` plus polling (`yield_now`) to observe that 4 resolver calls started. Under heavy load, the spawned tasks might not all get scheduled within 1 second, causing a spurious failure.

## Issue Context
This only affects test reliability, but it can create intermittent CI failures.

## Fix Focus Areas
- pnpm/crates/network/src/tests.rs[57-97]

## Suggested approach
- Replace the polling+timeout with deterministic synchronization:
 - Add a `tokio::sync::Notify` or `Barrier` that the `RecordingResolver` signals when `active_count` reaches 4.
 - Await that notification (optionally with a more generous timeout as a backstop).
- Alternatively, increase the timeout substantially (e.g. 5–10s) to reduce flake probability, but prefer a notify/barrier for determinism.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 6e85b10

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

CategorySuggestion                                                                                                                                    Impact
Possible issue
Preserve limits across request cancellation

Wrap the DNS resolution logic in a tokio::spawn task that takes ownership of the
semaphore permit. This ensures the permit is held for the full duration of the
non-cancellable blocking DNS call, even if the request future is cancelled.

pnpm/crates/network/src/lib.rs [600-613]

 impl<Inner> Resolve for CappedDnsResolver<Inner>
 where
     Inner: Resolve + 'static,
 {
     fn resolve(&self, name: Name) -> Resolving {
         let inner = Arc::clone(&self.inner);
         let permits = Arc::clone(&self.permits);
         Box::pin(async move {
-            let _permit =
+            let permit =
                 permits.acquire_owned().await.expect("DNS concurrency semaphore is never closed");
-            inner.resolve(name).await
+            tokio::spawn(async move {
+                let _permit = permit;
+                inner.resolve(name).await
+            })
+            .await
+            .map_err(|error| {
+                Box::new(error) as Box<dyn std::error::Error + Send + Sync>
+            })?
         })
     }
 }
  • Apply / Chat
Suggestion importance[1-10]: 10

__

Why: This addresses a critical bug where cancellation of the outer future drops the semaphore permit prematurely, causing blocking getaddrinfo calls to pile up and defeat the PR's concurrency limit mechanism.

High
  • More

Previous suggestions

Suggestions up to commit 6d7a51f
CategorySuggestion                                                                                                                                    Impact
Possible issue
Preserve DNS cap during cancellation

Run the permit-owning resolution in a spawned Tokio task to detach it on
cancellation. This prevents premature release of the concurrency semaphore when
requests timeout.

pnpm/crates/network/src/lib.rs [607-611]

 Box::pin(async move {
-    let _permit =
-        permits.acquire_owned().await.expect("DNS concurrency semaphore is never closed");
-    inner.resolve(name).await
+    tokio::spawn(async move {
+        let _permit = permits
+            .acquire_owned()
+            .await
+            .expect("DNS concurrency semaphore is never closed");
+        inner.resolve(name).await
+    })
+    .await
+    .map_err(|error| Box::new(error) as Box<dyn std::error::Error + Send + Sync>)?
 })
Suggestion importance[1-10]: 9

__

Why: Spawning a separate task ensures the semaphore permit is held until the underlying blocking getaddrinfo call completes, correctly enforcing the concurrency limit even when the requesting future is cancelled.

High

The scoped-DNS fix lives entirely in pnpm/crates/network (pacquet); in
changesets `pnpm` means the TypeScript CLI, which is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@@ -0,0 +1,5 @@
---
"pacquet": patch

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. pnpm missing changeset entry 📘 Rule violation § Compliance

The new changeset declares a bump for pacquet but does not include the required pnpm entry. This
violates the changeset policy and can prevent pnpm from being versioned/released correctly for
this fix.
Agent Prompt
## Issue description
The changeset front-matter is missing a required `pnpm` entry.

## Issue Context
Compliance requires every changeset to explicitly declare a `pnpm` bump (`patch`/`minor`/`major`) when relevant.

## Fix Focus Areas
- .changeset/calm-cats-resolve.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6e85b10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants