Make the Promise timeout value configurable #1002

nraychaudhuri opened this Issue Apr 12, 2013 · 18 comments


None yet

nraychaudhuri commented Apr 12, 2013

Promise.timeout right now uses a default timeout value. It will be nice to get this value from the conf file.

tavlima commented Apr 14, 2013


The timeout error happens mostly when stepping through debug, while testing.

@ghost ghost assigned richdougherty May 15, 2013

fosple commented May 24, 2013


fosple commented May 31, 2013

Still getting the error "java.util.concurrent.TimeoutException: Futures timed out after [10000 milliseconds]", if a promise takes too long to be fulfilled.

Please fix the TODO described in the following code segment and get the timeout value from the config file.

private[play] lazy val defaultTimeout = //TODO get it from conf Duration(10000, TimeUnit.MILLISECONDS).toMillis

Thanks :)


richdougherty commented Jun 4, 2013

@fosple, can you please post the stack trace for that exception? There should be methods you can use that let you control the timeout value so you can avoid the error. In #1102 F.Promise.get() and F.Promise.timeout() were deprecated in favour of methods where the timeout value can be passed explicitly.

fosple commented Jun 5, 2013

I discovered the error only occurs if I use the "recover" function (

java.lang.RuntimeException: java.util.concurrent.TimeoutException: Futures timed
 out after [10000 milliseconds]
        at play.libs.F$Promise$6.apply(
        at scala.concurrent.Future$$anonfun$map$1.liftedTree2$1(Future.scala:253
        at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:249)
        at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:249)
        at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.liftedTree1$1(BatchingExecutor.scala:67)
        at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.processBatch$1(BatchingExecutor.scala:66)
        at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:82)
        at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.apply(BatchingExecutor.scala:59)
        at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.apply(BatchingExecutor.scala:59)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72
        at akka.dispatch.BatchingExecutor$
        at scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(
Caused by: java.util.concurrent.TimeoutException: Futures timed out after [10000 milliseconds]
        at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:96)
        at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:58)
        at scala.concurrent.Await$$anonfun$ready$1.apply(package.scala:86)
        at scala.concurrent.Await$$anonfun$ready$1.apply(package.scala:86)
        at akka.dispatch.MonitorableThreadFactory$AkkaForkJoinWorkerThread$$anon$3.block(ThreadPoolBuilder.scala:173)
        at scala.concurrent.forkjoin.ForkJoinPool.managedBlock(
        at akka.dispatch.MonitorableThreadFactory$AkkaForkJoinWorkerThread.block
        at scala.concurrent.Await$.ready(package.scala:86)
        at play.api.libs.concurrent.PlayPromise.await(Promise.scala:134)
        at play.api.libs.concurrent.PlayPromise.await(Promise.scala:126)
        at play.api.libs.concurrent.PlayPromise.value1(Promise.scala:119)
        at play.libs.F$Promise.get(
        at controllers.MyApp.update(

        at controllers.MyApp$2.apply(
        at controllers.MyApp$2.apply(
        at play.libs.F$Promise$PromiseActor.onReceive(
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230)
        at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:502)

mcornejo commented Jun 5, 2013

In testing, I had the same problem. After a lot of page visited I found this link:

These Gist give me some ideas, and it solves my problem, importing play.api.test.Helpers._ and then changing the timeout:

import play.api.test.Helpers._
await[Result](route(FakeRequest(POST, "/method")).get.asInstanceOf[AsyncResult].result, 100000)

-- Mario


richdougherty commented Jun 6, 2013

@fosple, this should be fixed in master with #1102. Are you testing against master?

fosple commented Jun 6, 2013

@richdougherty I'm using the master branch (#1133).

In fact #1102 really fixes the error. You were right! After upgrading to the master branch I forgot to add a timeout to one get() function. Sorry!


richdougherty commented Jul 16, 2013

@nraychaudhuri Are you happy that this is fixed? The timeout value can now be passed as an argument to the methods of F.Promise. There was also a 1 hour timeout buried inside the F.Promise implementation that has been removed.


nraychaudhuri commented Jul 16, 2013

Sounds good. Thx @richdougherty

@jroper jroper closed this Jul 26, 2013

angeloh commented Apr 15, 2014

For anyone who see this thread, this is how I test on Play 2.2 to increase timeout value.

status(resp)(akka.util.Timeout(200000)) must equalTo(OK)

Is this fix backported to Play 2.1 (specifically 2.1.1)?


jroper commented Jul 20, 2014

I don't think so.

@jroper Which version did this fix go into? Is it fixed in 2.2.4?


jroper commented Oct 21, 2014

It was fixed in 2.2.0.

what is the conf to change default promise timeout? i'm not found.


cchantep commented Feb 21, 2015

@bdmstyle this issue is close. Please ask question on the Mailing List.

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