This is partially guesswork, but the code to catchWSError looks dubious:

    catchWsError :: WebSockets p a
             -> (SomeException -> WebSockets p a)
             -> WebSockets p a
  catchWsError act c = WebSockets $ do
      env <- ask
      let it  = peelWebSockets env $ act
          cit = peelWebSockets env . c
      lift $ it `E.catchError` cit
    where
      peelWebSockets env = flip runReaderT env . unWebSockets

Look at `cit`. It runs the recovery function, then hands the underlying Iteratee the existing environment. That's fine if `act` is at fault, but there are Iteratee- and IO-ish things in WebSocketsEnv---if one of `envSink` or `envSendBuilder` is causing the exception, it'll just get re-thrown after `E.catchError`. (I think. That's the guesswork part.)
So check how `envSendBuilder` is built up, and see if there's a way it could throw an exception on client disconnect.


On Tue, Aug 27, 2013 at 10:28 AM, Yuras Shumovich <shumovichy@gmail.com> wrote:
Hello,

I'm debugging an issue in "websockets" package,
https://github.com/jaspervdj/websockets/issues/42

I'm not familiar with "enumerator" package (websockets are based on it),
so I'm looking for help. The exception is throws inside "enumSocket"
enumerator using
"throwError" ( http://hackage.haskell.org/packages/archive/network-enumerator/0.1.5/doc/html/src/Network-Socket-Enumerator.html#enumSocket ), but I can't catch it with "catchError". It is propagated to "run" function:
   <interactive>: recv: resource vanished (Connection reset by peer)

The question is: how is it possible? could it be a bug in "enumerator"
package?

Thanks,
Yuras


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe