All Products
Search
Document Center

Function Compute:Troubleshoot the "Invocation canceled by client" error

Last Updated:Feb 28, 2026

The "Invocation canceled by client" error occurs when the client that invoked a function disconnects before the function finishes executing. Function Compute interrupts the execution and logs the error.

Error message

The following error appears in the request log:

FC Invoke End RequestId: 1-64263a4b-2cd7c98b677*********, Error: Invocation canceled by client (duration: 4912ms, maxMemoryUsage: 0.00MB)

Cause

The client that initiated the invocation canceled the request before the function completed. This interrupts function execution and produces the error.

Common triggers include:

  • The client-side request timeout is shorter than the function execution duration.

  • A user manually canceled the request (for example, by clicking Cancel Request in the Function Compute console or closing the browser tab).

  • An intermediary service (such as API Gateway) enforced a backend timeout shorter than the function execution duration.

Solution

Step 1: Check the execution duration

Extract the duration value from the error message. This tells you how long the function ran before the client disconnected.

In the example above, duration: 4912ms means the function ran for approximately 5 seconds.

Step 2: Determine whether the duration is expected

Compare the duration against your expected execution time for this function. The answer determines which path to follow:

Increase client-side timeout

If the function execution duration is within expectations, the client timeout is too short. Adjust timeout settings based on how you invoke the function:

SDK or API invocation

Set the client-side request timeout to a value greater than the configured function timeout.

Go example: Configure the timeout through the Timeout property in http.Client. If you use context.Context when initiating the request, adjust the deadline or timeout of the context.

// Set the HTTP client timeout to 120 seconds
client := &http.Client{
    Timeout: 120 * time.Second,
}

Invocation through another service

If another Alibaba Cloud service (such as API Gateway) triggers the function, modify the backend timeout of that service.

API Gateway example: Adjust the backend timeout settings in the API Gateway console. For details, see Create an API.

Console invocation

When you invoke a function from the Function Compute console, do not click Cancel Request or close the browser tab before the function finishes executing.

Reduce function execution time

If the function takes longer than expected, identify the bottleneck by examining your function logs. The two most common causes are I/O latency and compute-intensive operations.

I/O operations

Network I/O is the primary cause of unexpected latency. Add logging before and after each external call (database queries, API requests, storage operations) to isolate the slow call.

import time, logging

start = time.time()
# Call to external service
response = external_service.query(params)
logging.info(f"External service call took {time.time() - start:.2f}s")

Computing operations

CPU-intensive operations can also increase execution duration. If profiling confirms a compute bottleneck, increase the CPU specifications allocated to the function.