Skip to content

Fix HappyEyeballsConnector leaked-promise crash on failed connect#1

Closed
tabmail-kmyi wants to merge 1 commit into
mainfrom
fix/bypass-happy-eyeballs-leaked-promise
Closed

Fix HappyEyeballsConnector leaked-promise crash on failed connect#1
tabmail-kmyi wants to merge 1 commit into
mainfrom
fix/bypass-happy-eyeballs-leaked-promise

Conversation

@tabmail-kmyi

Copy link
Copy Markdown

Summary

  • Bypass NIO's HappyEyeballsConnector by resolving DNS up-front with SocketAddress.makeAddressResolvingHost() and using bootstrap.connect(to:) instead of bootstrap.connect(host:port:)
  • When TCP connection fails (e.g. no network during IDLE reconnect), the connector can be deallocated with unfulfilled internal promises, triggering a fatal assertion in EventLoopFuture.deinit (debug builds only — release builds silently leak)
  • Adds two tests verifying unresolvable hosts and refused ports fail cleanly without crashes

Test plan

  • swift test — all 242 tests pass (240 existing + 2 new)
  • Verify IDLE reconnect after network loss no longer crashes in debug builds

🤖 Generated with Claude Code

When TCP connection fails (e.g. no network during IDLE reconnect),
NIO's HappyEyeballsConnector can be deallocated with unfulfilled
internal promises, triggering a fatal assertion in debug builds
(EventLoopFuture.deinit).

Bypass the connector entirely by resolving DNS up-front with
SocketAddress.makeAddressResolvingHost() and using
bootstrap.connect(to:) instead of bootstrap.connect(host:port:).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tabmail-kmyi tabmail-kmyi deleted the fix/bypass-happy-eyeballs-leaked-promise branch April 4, 2026 07:46
@tabmail-kmyi tabmail-kmyi restored the fix/bypass-happy-eyeballs-leaked-promise branch April 4, 2026 07:46
@tabmail-kmyi tabmail-kmyi deleted the fix/bypass-happy-eyeballs-leaked-promise branch April 4, 2026 09:04
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