denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

[Bug]: Docs do not provide clarity on whether asynchronous work can reliably complete after a response is returned #660

Open BernieSumption opened 4 months ago

BernieSumption commented 4 months ago

Problem description

The Deploy documentation does not contain any warnings not to perform work in the background after a response has been returned from a handler. I have tried this in a test app and it appears to work. But in other serverless environments it is forbidden and works intermittently or not at all.

Here's an example of what I mean:

Deno.serve((req) => {
  // initiate an async request, which will complete after response is returned.
  // We do not want to block the client response, and we don't care about retrying
  // if the request fails
  asyncRequestToLoggingService(req);
  return new Response(getResponseBody(req));
});

For context, the above pattern will not work reliably in Lambda, Netlify Functions or Vercel Functions, and requires modification (explicit use of context.waitUntil) to work reliably in CloudFlare Workers or Vercel Edge Functions.

Can the docs clarify whether Deno has the unique ability to do this kind of background processing in a serverless environment, or whether it is unreliable/forbidden?

Steps to reproduce

n/a

Expected behavior

Docs should provide clarity on whether all processing must be completed by the time that the response is returned

Environment

No response

Possible solution

No response

Additional context

No response