Skip to content

Add a dynamic resolver factory for reusable bootstraps - #3692

Draft
aryansk wants to merge 1 commit into
apple:mainfrom
aryansk:codex/issue-2434-dynamic-resolver
Draft

aryansk wants to merge 1 commit into
apple:mainfrom
aryansk:codex/issue-2434-dynamic-resolver

Conversation

@aryansk

@aryansk aryansk commented Aug 5, 2026

Copy link
Copy Markdown

Motivation:
ClientBootstrap currently stores one resolver instance, but DNS resolvers are generally single-use. Reusing a bootstrap with a single-use resolver makes it difficult to issue multiple hostname connections safely.

Modifications:

  • Add NIODynamicResolver, which creates a fresh resolver for each hostname connection.
  • Allow ClientBootstrap to use the dynamic resolver in both synchronous and async hostname-connect paths.
  • Add a concurrent connection regression test proving that each connection receives its own resolver and A/AAAA query pair.

Result:
A reusable ClientBootstrap can safely create fresh resolver instances for concurrent hostname connections. The factory boundary avoids the shared mutable pairing problem identified in the earlier closed PR #2553.

Testing:

  • swift test --filter NIODynamicResolverTest/testCreatesFreshResolverForConcurrentConnections
  • swift test --parallel
  • git diff --check

Closes #2434

Motivation: ClientBootstrap currently stores one resolver instance, but DNS resolvers are generally single-use. Reusing a bootstrap with such a resolver can mix or reuse resolver state across connections.

Modifications: Add NIODynamicResolver and configure ClientBootstrap to create one resolver per hostname connection, including the async path. Add a concurrent connection regression test.

Result: A reusable ClientBootstrap can safely create fresh resolver instances for concurrent hostname connections.
Signed-off-by: Aryan Singh K. <70511529+aryansk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClientBootstrap.resolver is hard to use for single-use resolvers

1 participant