it seems like reacitvemongo enumerators are not handling exceptions correctly. The code below consumes an enumerator ( returned by reactivemongo driver) to create a list, the problem here is that when there is an exception inside fold function the request hangs and the browser don't get a response at all ( the loader spins infinitely)
def specialTalks() = AdminAction.async {
implicit request => {
val query = Json.obj(("status" -> 3))
val res = talks.find(query).sort(Json.obj(("title" -> 1))).cursor[JsObject]
.enumerate() |>>> Iteratee.fold[JsObject, List[JsObject]](List[JsObject]())((theList, aTalk) => {
// an exception may happen here
if (((aTalk \ "hex").as[String]).length == 24)
theList :+ aTalk
else
theList
}).map(l => {
Ok(Json.toJson(Json.obj(("talks" -> l))))
})
res.recover({case _ => InternalServerError("Not a hex talk")})
}}
It doesn't even recover from the failing execution.
I'm I missing some thing here or it's a bug in reactivemongo enumerator ?