Skip to content

src: migrate deprecated c-ares APIs to modern replacements#62724

Open
om-ghante wants to merge 1 commit intonodejs:mainfrom
om-ghante:fix/52464-cares-deprecation-warnings
Open

src: migrate deprecated c-ares APIs to modern replacements#62724
om-ghante wants to merge 1 commit intonodejs:mainfrom
om-ghante:fix/52464-cares-deprecation-warnings

Conversation

@om-ghante
Copy link
Copy Markdown
Contributor

@om-ghante om-ghante commented Apr 14, 2026

Replace all deprecated c-ares function calls in cares_wrap.cc with
their modern equivalents, resolving all compiler deprecation warnings
reported in #52464.

DNS record parsing → ares_dns_parse + record iteration

The deprecated per-type parse functions are replaced with the unified
ares_dns_parse() API, which parses DNS wire format into an
ares_dns_record_t structure. Records are then iterated using typed
getter functions. This follows the same pattern already used by
ParseTlsaReply in this file.

Deprecated API Replacement
ares_parse_a_reply ares_dns_parse + ARES_RR_A_ADDR
ares_parse_aaaa_reply ares_dns_parse + ARES_RR_AAAA_ADDR
ares_parse_ns_reply ares_dns_parse + ARES_RR_NS_NSDNAME
ares_parse_ptr_reply ares_dns_parse + ARES_RR_PTR_DNAME
ares_parse_mx_reply ares_dns_parse + ARES_RR_MX_*
ares_parse_caa_reply ares_dns_parse + ARES_RR_CAA_*
ares_parse_txt_reply_ext ares_dns_parse + ares_dns_rr_get_abin
ares_parse_srv_reply ares_dns_parse + ARES_RR_SRV_*
ares_parse_naptr_reply ares_dns_parse + ARES_RR_NAPTR_*
ares_parse_soa_reply ares_dns_parse + ARES_RR_SOA_*

Server management → CSV-based APIs

Deprecated API Replacement
ares_get_servers_ports ares_get_servers_csv
ares_set_servers ares_set_servers_csv
ares_set_servers_ports ares_set_servers_ports_csv

Also removes the now-unused HostentToNames 3-argument overload
that was only called from the old ParseGeneralReply implementation.

Fixes: #52464

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. needs-ci PRs that need a full CI run. labels Apr 14, 2026
@om-ghante om-ghante force-pushed the fix/52464-cares-deprecation-warnings branch from d0750bf to 140cde3 Compare April 14, 2026 02:28
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 62.57669% with 122 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.74%. Comparing base (d080801) to head (abc640a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/cares_wrap.cc 62.57% 86 Missing and 36 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62724      +/-   ##
==========================================
- Coverage   91.55%   89.74%   -1.82%     
==========================================
  Files         355      699     +344     
  Lines      149381   216576   +67195     
  Branches    23364    41406   +18042     
==========================================
+ Hits       136765   194363   +57598     
- Misses      12354    14293    +1939     
- Partials      262     7920    +7658     
Files with missing lines Coverage Δ
src/cares_wrap.cc 58.76% <62.57%> (ø)

... and 463 files with indirect coverage changes

🚀 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.

Replace all deprecated c-ares function calls in cares_wrap.cc with
their modern equivalents, resolving 26 compiler deprecation warnings.

DNS record parsing (ares_dns_parse + record iteration):
- ares_parse_a_reply -> ares_dns_parse + ARES_RR_A_ADDR
- ares_parse_aaaa_reply -> ares_dns_parse + ARES_RR_AAAA_ADDR
- ares_parse_ns_reply -> ares_dns_parse + ARES_RR_NS_NSDNAME
- ares_parse_ptr_reply -> ares_dns_parse + ARES_RR_PTR_DNAME
- ares_parse_mx_reply -> ares_dns_parse + ARES_RR_MX_*
- ares_parse_caa_reply -> ares_dns_parse + ARES_RR_CAA_*
- ares_parse_txt_reply_ext -> ares_dns_parse + ares_dns_rr_get_abin
- ares_parse_srv_reply -> ares_dns_parse + ARES_RR_SRV_*
- ares_parse_naptr_reply -> ares_dns_parse + ARES_RR_NAPTR_*
- ares_parse_soa_reply -> ares_dns_parse + ARES_RR_SOA_*

Server management (CSV-based APIs):
- ares_get_servers_ports -> ares_get_servers_csv
- ares_set_servers -> ares_set_servers_csv
- ares_set_servers_ports -> ares_set_servers_ports_csv

The new ares_dns_parse API parses DNS wire format into an
ares_dns_record_t structure which is then iterated using typed
getter functions (ares_dns_rr_get_addr, ares_dns_rr_get_str,
ares_dns_rr_get_u16, etc.). This follows the same pattern already
used by ParseTlsaReply in this file.

Fixes: nodejs#52464
@om-ghante om-ghante force-pushed the fix/52464-cares-deprecation-warnings branch from 140cde3 to abc640a Compare April 14, 2026 08:27
@mcollina
Copy link
Copy Markdown
Member

CI is very red

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

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cares deprecation warnings

3 participants