The Less-Told Story of Socket Timeouts
summary
Ruby 4.0 adds open_timeout to Socket.tcp/TCPSocket.new so a single timeout covers name resolution through connection, solving cases where resolv_timeout and connect_timeout alone couldn’t bound total time under Fast Fallback (Happy Eyeballs v2). The implementation required switching name resolution to interruptible threads after abandoning getaddrinfo_a (which caused fork hangs), rejecting combinations of open_timeout with other timeouts, and enables Net::HTTP to drop the Timeout library.
AI-written summary · about
chapters (9)
- 0:00Introduction to socket timeouts
- 1:59Ruby 2.0 and early timeouts
- 4:34Ruby 2.7 and name resolution timeout
- 6:55Ruby 3.0 and getaddrinfo_a issues
- 9:47Ruby 3.3 and interruptible resolution
- 11:19Happy Eyeballs version 2
- 18:20Ruby 4.0 and open_timeout
- 27:08Net::HTTP timeout resolution
- 28:15Conclusion and thanks
related talks
26mTCP Sockets Programming in Ruby
36mThe Little Server That Could
23mStatistically Optimal API Timeouts
35mLet's build a simple HTTP server with Ruby
33mI Made a Slow Thing Fast
35mThe little server that could
30mOn Sockets and System Calls: Minimizing Context Switches for the Socket API
44mOutside the Web Box: Using Ruby for Other Protocols
