Whatever message this page gives is out now! Go check it out!

completeOnTimeout (Future method)

Last update:
May 18, 2026
If the Future does not finish in time, completes it with a default value you supply. Returns the same Future for chaining.

Description

completeOnTimeout is like orTimeout except that on timeout the Future completes normally with your fallback value instead of failing.

Returns

A Future (the same instance, for chaining).

Category

Asynchronous programming

Function syntax

future.completeOnTimeout(value, timeout)

Parameters

ParameterDescription
valueRequired. Default value to use if the Future times out (any type).
timeoutRequired. Timeout in milliseconds (numeric).

Example

Replace a slow task with a default, then combine with other futures (from product tests).

 <cfscript>
   f1 = runAsync(function()  {    
    sleep(200);    return 10;}).completeOnTimeout(0, 50);
   f2 = runAsync(function() { 
    return 20; });f3 = runAsync(function() { return 30; });
    allFuture = asyncAllOf([f1, f2, f3]);
    allFuture.get();
    writeOutput(f1.get() + f2.get() + f3.get()); // 50
</cfscript>
      

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page