Easy to reproduce unhandled EOF exception when using ZIO
See original GitHub issue(tested with 0.20.6, so not fixed by #2651)
When websocat
disconnects from an http4s websocket server using ZIO for the effect types and runtime, an EOF slips through somewhere.
I ran into the problem with Firefox but it turns out to be easily triggerable with websocat.
I’ve made a simple testcase available at: https://github.com/Dennis4b/test-http4s-websocket-eof-problem
Just run it:
sbt run
and then run websocat (I have version 1.2.0):
websocat ws://localhost:10080/wstest
, wait a second, press Ctrl-C
output appears in the server:
01:10:05.670 [scala-execution-context-global-99] DEBUG org.http4s.server.blaze.WSFrameAggregator - Stage WSFrameAggregator sending inbound command: Connected
01:10:05.670 [scala-execution-context-global-99] DEBUG org.http4s.blazecore.websocket.Http4sWSStage - Starting up.
>> Inputstream closed
>> Outputstream closed
01:10:06.863 [zio-default-async-26-1845069441] DEBUG org.http4s.blazecore.websocket.Http4sWSStage - Shutting down.
01:10:06.863 [zio-default-async-26-1845069441] DEBUG org.http4s.server.blaze.WSFrameAggregator - Shutting down.
01:10:06.863 [zio-default-async-26-1845069441] DEBUG org.http4s.server.blaze.WebSocketDecoder - Shutting down.
01:10:06.863 [zio-default-async-26-1845069441] DEBUG org.http4s.blazecore.IdleTimeoutStage - Shutting down idle timeout stage
01:10:06.864 [zio-default-async-26-1845069441] DEBUG org.http4s.blazecore.IdleTimeoutStage - Shutting down.
01:10:06.864 [zio-default-async-26-1845069441] DEBUG org.http4s.blaze.channel.nio1.NIO1HeadStage - Shutting down.
01:10:06.865 [blaze-selector-1] DEBUG org.http4s.blaze.channel.nio1.NIO1HeadStage - Stage NIO1HeadStage sending inbound command: Disconnected
01:10:06.865 [blaze-selector-1] DEBUG org.http4s.blazecore.IdleTimeoutStage - Shutting down idle timeout stage
01:10:06.865 [blaze-selector-1] DEBUG org.http4s.blazecore.IdleTimeoutStage - Shutting down.
01:10:06.865 [blaze-selector-1] DEBUG org.http4s.blazecore.IdleTimeoutStage - Stage IdleTimeoutStage sending inbound command: Disconnected
01:10:06.865 [blaze-selector-1] DEBUG org.http4s.server.blaze.WebSocketDecoder - Shutting down.
01:10:06.865 [blaze-selector-1] DEBUG org.http4s.server.blaze.WebSocketDecoder - Stage WebSocketDecoder sending inbound command: Disconnected
01:10:06.865 [blaze-selector-1] DEBUG org.http4s.server.blaze.WSFrameAggregator - Shutting down.
01:10:06.865 [blaze-selector-1] DEBUG org.http4s.server.blaze.WSFrameAggregator - Stage WSFrameAggregator sending inbound command: Disconnected
01:10:06.866 [blaze-selector-1] DEBUG org.http4s.blazecore.websocket.Http4sWSStage - Shutting down.
01:10:06.868 [zio-default-async-21-1845069441] ERROR org.http4s.blazecore.websocket.Http4sWSStage - Error closing Web Socket
org.http4s.blaze.pipeline.Command$EOF$: EOF
Fiber failed.
A checked error was not handled.
EOF
Fiber:281 was supposed to continue to:
a future continuation at fs2.internal.Algebra$.compileLoop(Algebra.scala:349)
a future continuation at fs2.internal.Algebra$.compile(Algebra.scala:167)
a future continuation at zio.ZIO.run(ZIO.scala:1080)
a future continuation at zio.interop.CatsEffect.bracketCase(catsjvm.scala:234)
a future continuation at fs2.Stream$CompileOps.foldChunks(Stream.scala:4023)
a future continuation at zio.interop.CatsConcurrentEffect.runAsync(catsjvm.scala:112)
Fiber:281 execution trace:
at fs2.internal.Algebra$.compileLoop(Algebra.scala:307)
at fs2.internal.CompileScope.openAncestor(CompileScope.scala:233)
at cats.effect.concurrent.Ref$SyncRef.get(Ref.scala:219)
at fs2.internal.Algebra$.compileLoop(Algebra.scala:306)
at fs2.internal.CompileScope.close(CompileScope.scala:219)
at cats.effect.concurrent.Ref$SyncRef.modify(Ref.scala:253)
at fs2.internal.CompileScope.close(CompileScope.scala:218)
at fs2.internal.CompileScope.close(CompileScope.scala:217)
.. snipped
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Unzip Error java.io.EOFException with java unzip code
i am getting this error when i try to unzip a large zip file of about 56MB it works fine for smaller ...
Read more >KeyEvent - Android Developers
A key press starts with a key event with ACTION_DOWN . If the key is held sufficiently long that it repeats, then the...
Read more >Fix list for IBM Integration Bus Version 10.0
IBM Integration Bus provides periodic fixes for Version 10.0. The following is a complete listing of available fixes for IBM Integration Bus and...
Read more >Android: OOM or "Broken delimiter occurred" error ... - YouTrack
ClosedReceiveChannelException : Unexpected EOF: expected 4096 more bytes at ... Using 5g band WiFi, it is easy to reproduce, because it's fast.
Read more >Bug listing with status UNCONFIRMED as at 2022/12/19 13 ...
... Bug:389015 - "dev-libs/libpki - Provide an easy-to-use PKI library and tools ... Bug:631228 - "dev-lang/rakudo-2017.08 - Unhandled exception: Missing or ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Dennis4b @rossabaker
Any third-party effect type that is “run” to a concrete type such as
SyncIO
(which is really CatsIO
in disguise) has to be fully evaluated by the third-party runtime system. If, to avoid the loss of information, the runtime system logs unhandled errors (as ZIO does, and probably Monix), then such a conversion point will generated logged errors.The runtime system has no way of knowing what will happen “after” the conversion; this is an information-theoretic limitation and cannot be “solved”.
The best possible solution would be to never materialize an
F[_]
into a concrete Cats IO data type; failing that, pushing errors into values viaattempt
through such conversion points would avoid the issue; and failing that, spot fixes such as the above could work in some cases.For anyone who’s wondering how to turn of these error messages: you can always disable uncaught error logging in
Platform.withReportFailure
- https://github.com/zio/zio/blob/master/core/shared/src/main/scala/zio/internal/Platform.scala#L82