Api with async call die

What is the issue or error you’re encountering

I use sveltekit but this is a cloudflare side problem. The server-side is killed after returning. the frontend make a call to the backend which have heavy processing, because of that I want to return an early response and use polling to period`ically check if the computation is done

What steps have you taken to resolve the issue?

This is my backend

export function POST() {
  train(); // Async
  return new Response(null, { status: 200 });
}

The computation is too long so I can’t make a synchronous call, the http request would die before it ends. But Once the return is executed, the process is killed and the application doesn’t actually execute the function train

What are the steps to reproduce the issue?

Return before the end of an async call in the backend