Skip to content

Allow hiding handler error #938

@tlienart

Description

@tlienart

Hello,

These lines:

HTTP.jl/src/Servers.jl

Lines 453 to 456 in 32e84aa

# The remote can close the stream whenever it wants to, but there's nothing
# anyone can do about it on this side. No reason to log an error in that case.
level = e isa Base.IOError && !isopen(c) ? Logging.Debug : Logging.Error
@logmsgv 1 level "handle_connection handler error" exception=(e, stacktrace(catch_backtrace()))

can cause the kind of error message in LiveServer (see details below). It doesn't stop the server (good) but the error message is obscure and the user cannot do anything about it + it doesn't affect them. Could we have a toggle to hide this error message? something that would allow me to write in LS

req_handler = HTTP.streamhandler(show_errors=false) do req
  ...
end

so that the handle_connection function doesn't apply the @logmsgv ... line.

Thanks

Details
┌ LogLevel(1999): handle_connection handler error
│   exception =
│    IOError: write: broken pipe (EPIPE)
│    Stacktrace:
│      [1] uv_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
│        @ Base ./stream.jl:1064
│      [2] unsafe_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
│        @ Base ./stream.jl:1118
│      [3] unsafe_write(c::HTTP.ConnectionPool.Connection, p::Ptr{UInt8}, n::UInt64)
│        @ HTTP.ConnectionPool ~/.julia/packages/HTTP/VAOuj/src/ConnectionPool.jl:105
│      [4] unsafe_write(http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Connection}, p::Ptr{UInt8}, n::UInt64)
│        @ HTTP.Streams ~/.julia/packages/HTTP/VAOuj/src/Streams.jl:94
│      [5] write(io::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Connection}, s::String)
│        @ Base ./strings/io.jl:244
│      [6] write(io::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Connection}, s::Base.CodeUnits{UInt8, String})
│        @ Base ./strings/basic.jl:758
│      [7] (::HTTP.Handlers.var"#1#2"{LiveServer.var"#16#20"{typeof(identity), Bool, Bool, LiveServer.SimpleWatcher}})(stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Connection})
│        @ HTTP.Handlers ~/.julia/packages/HTTP/VAOuj/src/Handlers.jl:61
│      [8] (::LiveServer.var"#25#26"{HTTP.Handlers.var"#1#2"{LiveServer.var"#16#20"{typeof(identity), Bool, Bool, LiveServer.SimpleWatcher}}})(http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Connection})
│        @ LiveServer ~/.julia/packages/LiveServer/t2p5e/src/server.jl:606
│      [9] #invokelatest#2
│        @ ./essentials.jl:729 [inlined]
│     [10] invokelatest
│        @ ./essentials.jl:726 [inlined]
│     [11] handle_connection(f::Function, c::HTTP.ConnectionPool.Connection, listener::HTTP.Servers.Listener{Nothing, Sockets.TCPServer}, readtimeout::Int64, access_log::Nothing)
│        @ HTTP.Servers ~/.julia/packages/HTTP/VAOuj/src/Servers.jl:442
│     [12] (::HTTP.Servers.var"#16#17"{LiveServer.var"#25#26"{HTTP.Handlers.var"#1#2"{LiveServer.var"#16#20"{typeof(identity), Bool, Bool, LiveServer.SimpleWatcher}}}, HTTP.Servers.Listener{Nothing, Sockets.TCPServer}, Set{HTTP.ConnectionPool.Connection}, Int64, Nothing, Base.Semaphore, HTTP.ConnectionPool.Connection})()
│        @ HTTP.Servers ./task.jl:484
└ @ HTTP.Servers ~/.julia/packages/HTTP/VAOuj/src/Servers.jl:456

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions