Skip to content

Instantly share code, notes, and snippets.

@glasserc
Created November 18, 2015 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glasserc/3f45ffbc4b461ea68ca6 to your computer and use it in GitHub Desktop.
Save glasserc/3f45ffbc4b461ea68ca6 to your computer and use it in GitHub Desktop.
mongo-bug: ConnectionFailure <socket: 3>: hPutBuf: illegal operation (handle is closed)
{-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-}
import Database.MongoDB
import Control.Exception
import Control.Monad.Trans (liftIO)
main = do
pipe <- connect (host "127.0.0.1")
e1 <- access pipe master "baseball" badQuery `catch` recover
e2 <- access pipe master "baseball" goodQuery
close pipe
print e2
badQuery = findOne $ select [error "argh!!!"] "team"
goodQuery = findOne $ select ["name" =: "Yankees"] "team"
recover :: SomeException -> IO (Maybe Document)
recover e = return Nothing
@jasonzoladz
Copy link

Did you find a solution for this? I just got the same bug.

@VictorDenisov
Copy link

VictorDenisov commented Jun 8, 2016

It will be fixed in mongodb driver 2.1.0. Yet to be released though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment