JuliaPluto / PlutoSliderServer.jl

Web server to run just the `@bind` parts of a Pluto.jl notebook
https://computationalthinking.mit.edu/
The Unlicense
130 stars 17 forks source link

Random Error Messages: ┌ Error: handle_connection handler error #106

Open behinger opened 1 year ago

behinger commented 1 year ago

After talking to @fonsp I will start to report my random error messages from now on ;)

This one appears when I just started the sliderserver. Julia 1.8.3, [2fc8631c] PlutoSliderServer v0.3.21

Prior to this I had killed all julia processes on my virtual machine (centos 7)

I have seen the error before, it didnt affect my notebooks in any way. No entry in journalctl

┌ Info:
│   Starting server...
│   ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
└   address = "http://0.0.0.0:8082/"

[ Info: Listening on: 0.0.0.0:8082, thread id: 1

┌ Info:
│   Server started
└   ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

┌ Info: Notebook list updated
│   added =
│    7-element Vector{String}:
│     "unfoldSimDemo.jl"
│     "splineRegression.jl"
│     "lmmType1.jl"
│     "heatmap.jl"
│     "filterArtefacts.jl"
│     "deconvolution.jl"
│     "clusterPermutationTest.jl"
│   updated = String[]
└   removed = String[]

┌ Info:
│   ◐ [1/7] Launching...
└   s.path = "unfoldSimDemo.jl"

    Updating registry at `~/.julia/registries/General.toml`
┌ Warning: The project dependencies or compat requirements have changed since the manifest was last resolved. It is recommended to Pkg.resolve() or consider Pkg.update() if necessary.
└ @ Pkg.API /cache/build/default-amdci5-6/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/Pkg/src/API.jl:1532

┌ Error: 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
│        @ ~/.julia/packages/HTTP/z8l0i/src/ConnectionPool.jl:107 [inlined]
│      [4] unsafe_write(http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Connection{Sockets.TCPSocket}}, p::Ptr{UInt8}, n::UInt64)
│        @ HTTP.Streams ~/.julia/packages/HTTP/z8l0i/src/Streams.jl:93
│      [5] write
│        @ ./strings/io.jl:244 [inlined]
│      [6] write(io::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Connection{Sockets.TCPSocket}}, s::Base.CodeUnits{UInt8, String})
│        @ Base ./strings/basic.jl:758
│      [7] (::HTTP.Handlers.var"#1#2"{PlutoSliderServer.var"../HTTPRouter.jl".var"#27#28"{HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}}})(stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Connection{Sockets.TCPSocket}})
│        @ HTTP.Handlers ~/.julia/packages/HTTP/z8l0i/src/Handlers.jl:61
│      [8] #invokelatest#2
│        @ ./essentials.jl:729 [inlined]
│      [9] invokelatest
│        @ ./essentials.jl:726 [inlined]
│     [10] handle_connection(f::Function, c::HTTP.ConnectionPool.Connection{Sockets.TCPSocket}, listener::HTTP.Servers.Listener{Nothing, Sockets.TCPServer}, readtimeout::Int64, access_log::Nothing)
│        @ HTTP.Servers ~/.julia/packages/HTTP/z8l0i/src/Servers.jl:447
│     [11] (::HTTP.Servers.var"#16#17"{HTTP.Handlers.var"#1#2"{PlutoSliderServer.var"../HTTPRouter.jl".var"#27#28"{HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}}}, HTTP.Servers.Listener{Nothing, Sockets.TCPServer}, Set{HTTP.ConnectionPool.Connection}, Int64, Nothing, Base.Semaphore, HTTP.ConnectionPool.Connection{Sockets.TCPSocket}})()
│        @ HTTP.Servers ./task.jl:484
└ @ HTTP.Servers /home/bene/.julia/packages/HTTP/z8l0i/src/Servers.jl:461
fonsp commented 1 year ago

Thanks! I have also seen this error sometimes. It looks like this happens when a visitor of the site makes a request (i.e. moves a slider), and while the response from PSS is still coming in, they close the tab, closing the TCP connection.

You can see that the entire stack trace happens inside HTTP.jl and Julia Base, and it goes through this line: https://github.com/JuliaWeb/HTTP.jl/blob/a3a576807a4ecddcefa8d76f9efd07ea2b309f8e/src/Handlers.jl#L61 , which is where HTTP.jl takes the data that we want to send in the HTTP response and actually transmits it over the TCP connection.

Since this exception is safe to ignore, we should add a check and hide this specific error.

fonsp commented 1 year ago

It might be cleanest to make a copy of https://github.com/JuliaWeb/HTTP.jl/blob/a3a576807a4ecddcefa8d76f9efd07ea2b309f8e/src/Handlers.jl#L53-L64 and add a specific try catch around the write call.