CloudCode Task Timeout

I’m running a task that is loading data from another database JA DB and it’s timing out. How can I keep the task from restarting?

You can add the following to your task to catch timeouts and high memory usage.

export async function run(event) {

    this.on('beforeTimeout', () => {
        // The task is about to timeout, just return.
        // You can also report errors to log services
        return;
    });
    this.on('highMemory', () => {
        // The task is reaching the memory threshold, just return.
        // You can also report errors to log services
        return;
    });

}

If the beforeTimeout or highMemory events trigger, one should consider changing the task or enqueue another task to continue.

1 Like