Skip to main content

Background work

Choose between post-response work and durable background jobs.

Some application work does not need to block the HTTP response. Easel supports framework APIs that register post-response work within the active Function lifecycle.

Post-response work is not a durable job queue.

Post-response work

A supported framework API can return the response and continue work before the invocation ends.

For example, Next.js provides after():

import { after } from "next/server";

export async function POST(request: Request) {
  const event = await request.json();

  after(async () => {
    await recordAnalyticsEvent(event);
  });

  return Response.json({ accepted: true });
}

The client can receive the response before the callback completes, but the Function remains active and continues consuming duration.

Appropriate uses

Post-response work is appropriate for short, best-effort tasks such as:

  • Recording non-critical analytics
  • Updating a secondary cache
  • Sending a lightweight notification
  • Completing a bounded cleanup step

Use a durable job system when work

  • Must survive Function termination
  • Requires automatic retries
  • May exceed the Function duration limit
  • Must run independently of the originating request
  • Requires scheduling, fan-out, or concurrency control
  • Must guarantee eventual completion

A durable pattern is:

HTTP request

Validate and persist job

Return 202 Accepted

Worker processes job with retries

Failure behavior

A successful HTTP response does not prove that post-response work completed. Log failures and make non-idempotent operations safe to retry when possible.

Limits

Post-response work shares the Function's duration, memory, CPU, networking, and shutdown boundaries. See Function limits.