#WorkerdBackgroundTaskProvider
#Import
1import { WorkerdBackgroundTaskProvider } from "alepha/background";
#Overview
Cloudflare Workers variant of {@link BackgroundTaskProvider}.
Cloudflare freezes the isolate once the response is returned, so a plain
fire-and-forget promise would be killed mid-flight. The platform exposes a
per-request executionCtx.waitUntil(promise) that keeps the isolate alive
until promise settles; the request entry point (generated by the Cloudflare
build) stashes it in the Alepha store under cloudflare.waitUntil.
This is the ONE place that reads that key — call sites use {@link BackgroundTaskProvider.defer} and stay platform-agnostic.
waitUntil is request-scoped, so defer() must be called within the
request's async context (which is where background work is scheduled). Outside
a request (e.g. a cron tick) the key is absent and we fall back to the base
fire-and-track behaviour.