Coder Social home page Coder Social logo

Comments (5)

straight-shoota avatar straight-shoota commented on August 16, 2024 3

Actually, I believe the correct and direct fix would be to move the original conversion from #system_connect to #connect:

--- i/src/socket.cr
+++ w/src/socket.cr
@@ -110,6 +110,7 @@ class Socket < IO
   # Tries to connect to a remote address. Yields an `IO::TimeoutError` or an
   # `Socket::ConnectError` error if the connection failed.
   def connect(addr, timeout = nil, &)
+    timeout = timeout.seconds unless timeout.is_a? ::Time::Span | Nil
     result = system_connect(addr, timeout)
     yield result if result.is_a?(Exception)
   end

I've had this in my development branch, but it must've gotten lost somewhere during refactoring and rebasing.

After this we can move forward with adding type restricitons to timeout and deprecating the overload which is not Time::Span?.

from crystal.

nobodywasishere avatar nobodywasishere commented on August 16, 2024 1

system_connect is used by Socket#connect, so this is a breaking change for it and its subclasses (IPSocket, TCPSocket, UDPSocket, etc.)

from crystal.

ysbaddaden avatar ysbaddaden commented on August 16, 2024 1

We won't fix #system_connect since it's undocumented internal API, but there should indeed be a deprecated override method for Socket#connect(addr, timeout = nil, &) to not break the public API 👍

from crystal.

Blacksmoke16 avatar Blacksmoke16 commented on August 16, 2024

Crystal::System is an internal implementation detail. So while this may be a breaking change, unless it affected some public API, it is allowed. Was how you discovered this using system_connect directly or?

from crystal.

straight-shoota avatar straight-shoota commented on August 16, 2024

Thanks for reporting and fixing. Apparently this got lost in the heat of the moment.

from crystal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.