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

whenCompleteAsync (Future method)

Last update:
May 18, 2026
Runs a callback on the async executor when this Future completes, whether it succeeds or fails. The callback receives the value (or null) and the error (or null).

Description

whenCompleteAsync is for logging, metrics, or releasing resources. It does not replace failed futures with a success value. If the original Future failed, the Future returned from the chain still fails when you call get(), even after your handler runs.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.whenCompleteAsync(action)

Parameters

ParameterDescription
actionRequired. A function (value, error). On success, error is null. On failure, value is typically null and error is set.

See also

Example

Observe success without changing the result.

 <cfscript>
    future = runAsync(function() { return "success"; });
    variables.test01Value = "";
    variables.test01HasError = false;
    completed = future.whenCompleteAsync(function(value, error) {    variables.test01Value = value;    variables.test01HasError = isNull(error) ? "false" : "true";});
    completed.get();
    writeOutput(variables.test01Value & ":" & variables.test01HasError); // success:false
</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