Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readuntil method ambiguity in 0.4.0 with HTTP #76

Closed
yakir12 opened this issue Oct 21, 2020 · 8 comments
Closed

readuntil method ambiguity in 0.4.0 with HTTP #76

yakir12 opened this issue Oct 21, 2020 · 8 comments

Comments

@yakir12
Copy link
Contributor

yakir12 commented Oct 21, 2020

utils.jl is missing in v0.4.0. My issue with this was that readuntil broke JSServe.

@SimonDanisch
Copy link
Member

There is a utils.jl file only in v0.4.0, which breaks HTTP.readuntil, by introducing an ambiguity.

@SimonDanisch
Copy link
Member

ERROR: MethodError: readuntil(::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, ::typeof(HTTP.Parsers.find_end_of_header), ::Int64) is ambiguous. Candidates:
  readuntil(t::HTTP.ConnectionPool.Transaction, f::Function, sizehint) in HTTP.ConnectionPool at /home/yakir/.julia/packages/HTTP/IAI92/src/ConnectionPool.jl:267
  readuntil(s::IO, delim::T, timeout::U; keep) where {T, U<:Real} in LibSerialPort at /home/yakir/.julia/packages/LibSerialPort/d8jfU/src/utils.jl:50
Possible fix, define
  readuntil(::HTTP.ConnectionPool.Transaction, ::T, ::U) where {T<:Function, U<:Real}

@yakir12 yakir12 changed the title utils.jl is missing utils.jl introduces a method ambiguity Oct 21, 2020
@IanButterworth IanButterworth changed the title utils.jl introduces a method ambiguity readuntil method ambiguity in 0.4.0 with HTTP Oct 21, 2020
@yakir12
Copy link
Contributor Author

yakir12 commented Oct 21, 2020

Here's my stacktrace:

julia> import LibSerialPort

julia> import JSServe

julia> handler(session, request) = ""
handler (generic function with 1 method)

julia> app = JSServe.Application(handler, "0.0.0.0", 8000)
┌ Error: (MethodError(readuntil, (T0  🔗    0↑     0↓🔒   1s 0.0.0.0:8000:8000 ≣16, HTTP.Parsers.find_end_of_header, 4096), 0x0000000000006cbb), Base.StackTraces.StackFrame[readuntil(::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, ::Function) at ConnectionPool.jl:269, readheaders(::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, ::HTTP.Messages.Request) at Messages.jl:471, startread(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at Streams.jl:155, handle_transaction(::JSServe.var"#20#22"{JSServe.Application}, ::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, ::HTTP.Servers.Server{Nothing,Sockets.TCPServer}; final_transaction::Bool) at Servers.jl:343, (::HTTP.Servers.var"#handle_transaction##kw")(::NamedTuple{(:final_transaction,),Tuple{Bool}}, ::typeof(HTTP.Servers.handle_transaction), ::Function, ::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, ::HTTP.Servers.Server{Nothing,Sockets.TCPServer}) at Servers.jl:338, handle_connection(::Function, ::HTTP.ConnectionPool.Connection{Sockets.TCPSocket}, ::HTTP.Servers.Server{Nothing,Sockets.TCPServer}, ::Int64, ::Int64) at Servers.jl:299, (::HTTP.Servers.var"#8#9"{JSServe.var"#20#22"{JSServe.Application},HTTP.Servers.Server{Nothing,Sockets.TCPServer},Base.RefValue{Int64},Int64,Int64,Bool,HTTP.ConnectionPool.Connection{Sockets.TCPSocket}})() at task.jl:356])
└ @ HTTP.Servers ~/.julia/packages/HTTP/IAI92/src/Servers.jl:264
ERROR: MethodError: readuntil(::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, ::typeof(HTTP.Parsers.find_end_of_header), ::Int64) is ambiguous. Candidates:
  readuntil(t::HTTP.ConnectionPool.Transaction, f::Function, sizehint) in HTTP.ConnectionPool at /home/yakir/.julia/packages/HTTP/IAI92/src/ConnectionPool.jl:267
  readuntil(s::IO, delim::T, timeout::U; keep) where {T, U<:Real} in LibSerialPort at /home/yakir/.julia/packages/LibSerialPort/d8jfU/src/utils.jl:50
Possible fix, define
  readuntil(::HTTP.ConnectionPool.Transaction, ::T, ::U) where {T<:Function, U<:Real}
Stacktrace:
 [1] readuntil(::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, ::Function) at /home/yakir/.julia/packages/HTTP/IAI92/src/ConnectionPool.jl:269
 [2] readheaders(::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, ::HTTP.Messages.Response) at /home/yakir/.julia/packages/HTTP/IAI92/src/Messages.jl:471
 [3] startread(::HTTP.Streams.Stream{HTTP.Messages.Response,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at /home/yakir/.julia/packages/HTTP/IAI92/src/Streams.jl:155
 [4] macro expansion at /home/yakir/.julia/packages/HTTP/IAI92/src/StreamRequest.jl:67 [inlined]
 [5] macro expansion at ./task.jl:332 [inlined]
 [6] request(::Type{HTTP.StreamRequest.StreamLayer{Union{}}}, ::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, ::HTTP.Messages.Request, ::Array{UInt8,1}; reached_redirect_limit::Bool, response_stream::Nothing, iofunction::Nothing, verbose::Int64, kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/yakir/.julia/packages/HTTP/IAI92/src/StreamRequest.jl:57
 [7] request(::Type{HTTP.TimeoutRequest.TimeoutLayer{HTTP.StreamRequest.StreamLayer{Union{}}}}, ::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, ::HTTP.Messages.Request, ::Array{UInt8,1}; readtimeout::Int64, kw::Base.Iterators.Pairs{Symbol,Union{Nothing, Bool},Tuple{Symbol,Symbol},NamedTuple{(:iofunction, :reached_redirect_limit),Tuple{Nothing,Bool}}}) at /home/yakir/.julia/packages/HTTP/IAI92/src/TimeoutRequest.jl:30
 [8] request(::Type{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.TimeoutRequest.TimeoutLayer{HTTP.StreamRequest.StreamLayer{Union{}}}}}, ::HTTP.URIs.URI, ::HTTP.Messages.Request, ::Array{UInt8,1}; proxy::Nothing, socket_type::Type{T} where T, reuse_limit::Int64, kw::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:iofunction, :reached_redirect_limit, :readtimeout),Tuple{Nothing,Bool,Int64}}}) at /home/yakir/.julia/packages/HTTP/IAI92/src/ConnectionRequest.jl:96
 [9] request(::Type{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.TimeoutRequest.TimeoutLayer{HTTP.StreamRequest.StreamLayer{Union{}}}}}}, ::HTTP.URIs.URI, ::Vararg{Any,N} where N; kw::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:iofunction, :reached_redirect_limit, :readtimeout),Tuple{Nothing,Bool,Int64}}}) at /home/yakir/.julia/packages/HTTP/IAI92/src/ExceptionRequest.jl:19
 [10] (::Base.var"#56#58"{Base.var"#56#57#59"{ExponentialBackOff,HTTP.RetryRequest.var"#2#3"{Bool,HTTP.Messages.Request},typeof(HTTP.request)}})(::Type{T} where T, ::Vararg{Any,N} where N; kwargs::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:iofunction, :reached_redirect_limit, :readtimeout),Tuple{Nothing,Bool,Int64}}}) at ./error.jl:288
 [11] #request#1 at /home/yakir/.julia/packages/HTTP/IAI92/src/RetryRequest.jl:44 [inlined]
 [12] request(::Type{HTTP.MessageRequest.MessageLayer{HTTP.RetryRequest.RetryLayer{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.TimeoutRequest.TimeoutLayer{HTTP.StreamRequest.StreamLayer{Union{}}}}}}}}, ::String, ::HTTP.URIs.URI, ::Array{Pair{SubString{String},SubString{String}},1}, ::Array{UInt8,1}; http_version::VersionNumber, target::String, parent::Nothing, iofunction::Nothing, kw::Base.Iterators.Pairs{Symbol,Integer,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:reached_redirect_limit, :readtimeout, :retries),Tuple{Bool,Int64,Int64}}}) at /home/yakir/.julia/packages/HTTP/IAI92/src/MessageRequest.jl:51
 [13] request(::Type{HTTP.BasicAuthRequest.BasicAuthLayer{HTTP.MessageRequest.MessageLayer{HTTP.RetryRequest.RetryLayer{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.TimeoutRequest.TimeoutLayer{HTTP.StreamRequest.StreamLayer{Union{}}}}}}}}}, ::String, ::HTTP.URIs.URI, ::Array{Pair{SubString{String},SubString{String}},1}, ::Array{UInt8,1}; kw::Base.Iterators.Pairs{Symbol,Integer,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:reached_redirect_limit, :readtimeout, :retries),Tuple{Bool,Int64,Int64}}}) at /home/yakir/.julia/packages/HTTP/IAI92/src/BasicAuthRequest.jl:28
 [14] request(::Type{HTTP.RedirectRequest.RedirectLayer{HTTP.BasicAuthRequest.BasicAuthLayer{HTTP.MessageRequest.MessageLayer{HTTP.RetryRequest.RetryLayer{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.TimeoutRequest.TimeoutLayer{HTTP.StreamRequest.StreamLayer{Union{}}}}}}}}}}, ::String, ::HTTP.URIs.URI, ::Array{Pair{SubString{String},SubString{String}},1}, ::Array{UInt8,1}; redirect_limit::Int64, forwardheaders::Bool, kw::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol,Symbol},NamedTuple{(:readtimeout, :retries),Tuple{Int64,Int64}}}) at /home/yakir/.julia/packages/HTTP/IAI92/src/RedirectRequest.jl:24
 [15] request(::String, ::String, ::Array{Pair{SubString{String},SubString{String}},1}, ::Array{UInt8,1}; headers::Array{Pair{SubString{String},SubString{String}},1}, body::Array{UInt8,1}, query::Nothing, kw::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol,Symbol},NamedTuple{(:readtimeout, :retries),Tuple{Int64,Int64}}}) at /home/yakir/.julia/packages/HTTP/IAI92/src/HTTP.jl:314
 [16] #get#12 at /home/yakir/.julia/packages/HTTP/IAI92/src/HTTP.jl:391 [inlined]
 [17] warmup(::JSServe.Application) at /home/yakir/.julia/packages/JSServe/9Z6uA/src/types.jl:333
 [18] JSServe.Application(::Function, ::String, ::Int64; verbose::Bool, routes::JSServe.Routes, websocket_routes::JSServe.Routes) at /home/yakir/.julia/packages/JSServe/9Z6uA/src/types.jl:407
 [19] JSServe.Application(::Function, ::String, ::Int64) at /home/yakir/.julia/packages/JSServe/9Z6uA/src/types.jl:398
 [20] top-level scope at REPL[5]:1

I'm on Julia 1.52 and:

(mwe) pkg> st
Status `~/.julia/dev/SimpleFanControl/mwe/Project.toml`
  [824d6782] JSServe v0.6.10
  [a05a14c7] LibSerialPort v0.4.0

@mgkuhn
Copy link
Collaborator

mgkuhn commented Nov 11, 2020

I think this was already fixed by #61, by removing readuntil from this package, in favour of changing more basic SerialPort methods such that the readuntil method for IO in Base now works for SerialPort as well. So this seems just a matter of releases having been rather slow.

@yakir12
Copy link
Contributor Author

yakir12 commented Nov 11, 2020

I got hit by this again. Due to low brain cell count, it took me 15 minutes to remember this whole story again... So yea, a release fixing this would be amazing and appreciated (by both my brain cells).

@mgkuhn
Copy link
Collaborator

mgkuhn commented Nov 18, 2020

Fixed in release v0.5.0, which no longer implements any readuntil method. Instead, the docstring for set_read_timeout gives an example of how you can use the readuntil methods from Base with a libserialport timeout.

@mgkuhn
Copy link
Collaborator

mgkuhn commented May 28, 2021

Could you please close this issue (to help us focus on the ones not yet fixed)?

@yakir12
Copy link
Contributor Author

yakir12 commented May 28, 2021

Absolutely!

@yakir12 yakir12 closed this as completed May 28, 2021
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

No branches or pull requests

3 participants