#WorkerdBackgroundTaskProvider
#Import
1import { WorkerdBackgroundTaskProvider } from "alepha/background";
#Overview
Cloudflare Workers variant of 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-invocation executionCtx.waitUntil(promise) that keeps the isolate alive
until promise settles; the fetch, scheduled and queue entry points
(generated by the Cloudflare build) stash it in the invocation's async context
under cloudflare.waitUntil.
This is the ONE place that reads that key - call sites use
BackgroundTaskProvider.defer and stay platform-agnostic.
waitUntil belongs to one invocation, so defer() must be called within
that async context (which is where background work is scheduled, a cron tick
included). Outside it the key is absent and we fall back to the base
fire-and-track behaviour.