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

orTimeout (Future method)

Last update:
May 18, 2026
Fails the Future with a timeout if it does not complete within a number of milliseconds. Returns the same Future for chaining.

Description

Call orTimeout on a Future to bound how long you wait for completion. If the Future does not finish in time, it completes with a timeout error. You can chain further stages after orTimeout.

Returns

A Future (the same instance, for chaining).

Category

Asynchronous programming

Function syntax

future.orTimeout(timeout)

Parameters

ParameterDescription
timeoutRequired. Timeout in milliseconds (numeric).

Example

Use a timeout on one branch so asyncAnyOf can prefer a fast path (from product tests).

<cfscript>
    f1 = runAsync(function() {    
        sleep(1000);    return "slow";}).orTimeout(500);
    f2 = runAsync(function() {    return "fast";});
    anyFuture = asyncAnyOf([f1, f2]);
    writeOutput(anyFuture.get()); // fast>
</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