fix(webtransport): prevent Chrome DNS port-scanning penalty #3357
+263
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix Chrome WebTransport DNS port-scanning penalty
Fixes #3286
Problem
Chrome has an anti-port-scanning mechanism that penalizes cancelled WebTransport requests. When a DNS-based multiaddr is dialed and cancelled before DNS resolution completes, Chrome stores the penalty against an empty string key instead of a specific IP address.
This causes ALL future DNS-based WebTransport dials to be penalized, not just dials to that specific host.
Solution
This PR adds DNS pre-resolution for WebTransport multiaddrs in Chrome only:
isChrome())hasDNSComponent())Key Changes
isChrome()function to detect Chrome/Chromium browsershasDNSComponent()to detect DNS-based multiaddrsresolveMultiaddrDNS()to create async boundary for Chromedial()to pre-resolve DNS before dialingdialSingleAddress()private method for cleaner separationHow It Works
The async boundary (
await setTimeout(0)) ensures we yield to the event loop, giving Chrome's internal DNS resolver time to complete before the WebTransport session is created:Test Results
✅ 22/22 tests passing in browser environment
✅ 22/22 tests passing in webworker environment
✅ All new Chrome DNS tests passing (11 new tests)
✅ No regressions in existing tests
New Tests Added
Browser Compatibility
Breaking Changes
None. This is a backward-compatible fix that only affects Chrome browsers with DNS-based multiaddrs.