Skip to content

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

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

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

Conversation

@omghante
Copy link
Copy Markdown
Contributor

@omghante omghante commented Apr 14, 2026

This PR resolves the deprecation warnings in src/cares_wrap.cc by using compiler pragmas to suppress the -Wdeprecated-declarations warnings across Clang, GCC, and MSVC.

As discussed with reviewers, a full migration to the modern replacement APIs (ares_dns_parse, ares_get_servers_csv, ares_set_servers_csv) will be tackled in a separate follow-up PR to avoid regressions with CNAME-TTL clamping and unscoped IPv6 link-local addresses.

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
@omghante omghante 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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.70%. Comparing base (d080801) to head (8014a4d).
⚠️ Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62724      +/-   ##
==========================================
- Coverage   91.55%   89.70%   -1.86%     
==========================================
  Files         355      706     +351     
  Lines      149381   218270   +68889     
  Branches    23364    41777   +18413     
==========================================
+ Hits       136765   195790   +59025     
- Misses      12354    14415    +2061     
- Partials      262     8065    +7803     
Files with missing lines Coverage Δ
src/cares_wrap.cc 61.64% <ø> (ø)

... and 475 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.

@omghante omghante 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

@omghante omghante force-pushed the fix/52464-cares-deprecation-warnings branch from abc640a to fedc05d Compare April 14, 2026 17:26
@omghante
Copy link
Copy Markdown
Contributor Author

omghante commented Apr 14, 2026

Thanks @mcollina! Fixed, all workflows are finally back to green! Feel free to take a look whenever you have a chance.

@omghante omghante force-pushed the fix/52464-cares-deprecation-warnings branch 14 times, most recently from a93485a to e5e76a2 Compare April 15, 2026 00:48
Comment thread test/parallel/test-dns.js
Comment thread test/parallel/test-dns.js
@omghante
Copy link
Copy Markdown
Contributor Author

omghante commented Apr 15, 2026

@mcollina I've reworked the approach now just suppressing the warnings with compiler pragmas instead of migrating APIs. Test file is fully untouched, all fe80:: cases preserved. Full API migration will be a follow-up PR.

Copy link
Copy Markdown
Contributor

@thisalihassan thisalihassan left a comment

Choose a reason for hiding this comment

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

Signed-off-by is missing, can you please ammend your commit?

Comment thread src/cares_wrap.cc Outdated
Comment thread src/cares_wrap.cc Outdated
Comment thread src/cares_wrap.cc Outdated
Suppress deprecation warnings for legacy c-ares APIs
(ares_parse_*_reply, ares_get_servers_ports, ares_set_servers_ports)
using compiler pragmas for Clang, GCC, and MSVC.

A full migration to the modern replacement APIs (ares_dns_parse,
ares_get_servers_csv, ares_set_servers_csv) is left as follow-up work.

Fixes: nodejs#52464
Signed-off-by: om-ghante <mr.omghante1@gmail.com>
@omghante omghante force-pushed the fix/52464-cares-deprecation-warnings branch from e5e76a2 to 8014a4d Compare April 18, 2026 09:47
@omghante
Copy link
Copy Markdown
Contributor Author

@thisalihassan Great catches, all valid. I've force-pushed a new approach just pragma-based warning suppression (13 lines, 1 file). No API migration, so the IPv6 link-local and CNAME-TTL clamping issues are gone. Signed-off-by added. Full migration can be a separate PR.

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

4 participants