AsyncStack serious issue
lunayo opened this issue · comments
It turns out that if there are two similar variables (especially, with the same name) which return future[result] to the stack, one of the variable will return Exception without any detail messages.
Detail on how to reproduce:
def functionA = AsyncStack(AuthorityKey -> UserRole.NormalUser) { implicit request =>
val someVariable: Future[Result] = collection.find()
someVariable.map { variable =>
...
}
}
def functionB = AsyncStack(AuthorityKey -> UserRole.NormalUser) { implicit request =>
val someVariable: Future[Result] = collection.find()
// someVariable return Java exception immediately
someVariable.map { variable< =>
...
}
}
This is standard behavior of Play2 ActionBuilder.
It reproduce as follows
def foo = Action.async { implicit request =>
throw new Exception("fooo")
}
You can report the failure by http://www.scala-lang.org/api/2.11.7/index.html#scala.concurrent.ExecutionContext@reportFailure%28cause:Throwable%29:Unit
or play2 error handling system https://www.playframework.com/documentation/2.4.2/ScalaErrorHandling