Skip to content

fix: CachingResolver falls back to stale addresses when refresh fails#3949

Open
guizmaii wants to merge 1 commit intomainfrom
fix/dns-resolver-stale-while-revalidate
Open

fix: CachingResolver falls back to stale addresses when refresh fails#3949
guizmaii wants to merge 1 commit intomainfrom
fix/dns-resolver-stale-while-revalidate

Conversation

@guizmaii
Copy link
Member

Summary

  • CachingResolver#resolve had a bug in its stale-while-revalidate logic: when a background DNS refresh failed, the previousAddresses were discarded and the UnknownHostException was propagated to callers, even though valid cached addresses were available
  • Fixed by adding .orElseSucceed(previous) so that a failed refresh falls back to the last known good addresses
  • Added a test that toggles the underlying resolver to fail mode after a successful cache, triggers a refresh, and verifies the stale addresses are returned

Test plan

  • New test resolve returns previous addresses when refresh fails passes
  • All existing DnsResolverSpec tests pass (5/5)

@netlify
Copy link

netlify bot commented Feb 11, 2026

Deploy Preview for zio-http ready!

Name Link
🔨 Latest commit 96dfc65
🔍 Latest deploy log https://app.netlify.com/projects/zio-http/deploys/698c2fe5b743d10008f11c50
😎 Deploy Preview https://deploy-preview-3949--zio-http.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

The stale-while-revalidate logic in CachingResolver#resolve discarded
previousAddresses when the refresh promise completed with a failure,
propagating UnknownHostException instead of returning the cached
addresses. Use orElseSucceed to fall back to the previous addresses
when the refreshed resolution fails.
@guizmaii guizmaii force-pushed the fix/dns-resolver-stale-while-revalidate branch from 0d1858c to 96dfc65 Compare February 11, 2026 07:29
@guizmaii guizmaii marked this pull request as ready for review February 11, 2026 07:42
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.

1 participant

Comments