@durable-sdk/vercel

The platform adapter: binding it, the wake modes, the adoption, the consumer, the route bindings.

Open in CursorView as Markdown

Generated from the SDK's own source (packages/durable-vercel/README.md) at build; edit there.

The Vercel platform adapter of the Durable SDK (ADR-0046 §F; §M step 5, both halves landed 2026-09-27). Private, 0.0.0, Apache-2.0. The one package that imports Vercel's runtime, and only the two modules the platform is made of: waitUntil from @vercel/functions and the Queues client from @vercel/queue; @durable-sdk/core is a peer (one copy in the consumer's graph: the adapter's inline drain and marker adoption read the instance the host bound). Nothing here imports a host, and the code carries no host's vocabulary (the package-imports guard). Four entry points: the root (the platform), ./consumer (the Queues consumer a host's root push function re-exports; it imports nothing of the core), ./react-router (the cron routes' bindings, the liveness probe's, the relay receiver's and, since ADR-0051's amendment of 2026-09-28, an inbound webhook's: webhookRoute({ durable?, verify, body?, toFacts, record?, methods? })) and, since ADR-0066 D01 (T05), ./plans (VERCEL_PLANS: one dated, sourced row per plan with Vercel's maxima, and planMaxDurationS(plan); a leaf with no import, what a host's pure platform module declares its plan against, vercelPlatform({ plan }) derives the limit from, and a host's pnpm gen:platform writes the route literals from). Since ADR-0066 D03 (T01) the platform object carries the function's kill as the platform's word: functionDeadline() reads Vercel's getDeadline() first and the binding's arrival plus the pin second (on a deployment role alone; a laptop's binding is no kill), reports { at, source: "platform" | "arrival" }, clamps a platform deadline later than the pin to the pin and says so once (platform.deadline_beyond_pin), and notes the source read once per process (platform.deadline_source, counted on count.platform.deadline_source.<source>.<day>).

What is here#

Module What
options.ts VercelPlatformOptions, the process's configuration (vercelPlatform() sets it; every helper reads it at each use), selfUrl(env?) and its variable ALIAS_URL_VARIABLE (DURABLE_ALIAS_URL), roleFromVercel(env?), identity(env?), keepAlive(p), the inline bounds INLINE_CONCURRENCY, INLINE_BACKLOG_MAX, INLINE_PASSES_MAX (a drain's statements run under the core's pool gate too, ADR-0076 FP-014: runPartitionTick enters it, so the drains and a batch wave together hold at most the store's pool less two in flight at once).
env.ts @durable-sdk/vercel/env: DURABLE_REQUIRED_ENV (DATABASE_URL, CRON_SECRET, ADMIN_TOKEN), missingDurableEnv(env?), assertDurableEnv(env?): the deployment's boot check for a host with no other required variables; names only, never values. Since ADR-0046 §M step 7 (PR 3) peersFromEnv({ members, self, env?, shorthand?, roles? }), the identity's peers resolver over durable.peers.json's members and the deployment's DURABLE_PEER_SECRET_<NAME> / _ACCEPT variables (EVERY_ROLE, resetPeerReportsForTests, the PeerMember and PeersFile types): a Secret<string> per peer, the file's members asserted first (a bad file throws PeerMisconfigured), a short secret or a bad shorthand URL dropped with one relay.peer_misconfigured { name, variable } line, the role gate (production alone by default).
platform.ts vercelPlatform(options); the wake by DURABLE_WAKE (wake, wakeMode(env?), selfTicks(), subMinute(): whether a delayed wake inside the minute is held, true under queue and inline on a plan whose cron runs every minute, ADR-0076 FP-036); the self kick (kickDispatch) and its per-process coalescing gate; the queue send (WAKE_TOPIC, WakeMessage, queueSendOptions, wakeMacInput, signWake, QUEUE_RETRY_AFTER_MS); the inline scheduler (scheduleInlineDrain, inlineDrains, resetInlineForTests).
deployment.ts The adoption of rule 7's deployment marker from the production alias (ADR-0045 amendment 2026-09-26): adoptOnAliasRequest(request, env?), adoptOnCronRequest(env?), adoptionSettled(), aliasHost(env?), requestHost(request), resetAdoptionForTests(); deployment.alias_unresolved once per process when a production deployment resolves no alias.
mac.ts The wake message's proof, spelled once for the publisher and the consumer: WAKE_TOPIC, MacFields, wakeMacInput, signWake, verifyWake (constant time). Imports node:crypto alone.
consumer.ts @durable-sdk/vercel/consumer: createConsumer(options?) → { handle, retry, POST }, ConsumerOptions, parseMessage, selfRequest, scrubError, FORWARD_TIMEOUT_MS, DEFAULT_DISPATCH_PATH, the mac trio and the topic re-exported. Imports @vercel/queue, node built-ins and ./mac.js alone: nothing of the core, nothing of a host.
react-router.ts @durable-sdk/vercel/react-router: dispatchLoader({ durable, cronSecret?, env? }), cronLoader({ run, cronSecret?, env? }), healthLoader({ durable, sha?, env? }), relayRoute({ durable, now? }) and webhookRoute({ durable?, verify, body?, toFacts, record?, methods? }) (with WebhookVerdict, WebhookVerify, WebhookBody, WebhookBodyRefusal, WebhookFact, WebhookFacts, WebhookRouteOptions), each answering a ({ request }) => Promise<Response> (the relay route answers { loader, action }); no react-router import.

| functions.ts | @durable-sdk/vercel/functions (ADR-0105 D09): the route bindings as Vercel Functions, (request: Request) => Promise<Response> named method exports. asFunction(handler, { env? }) runs the host guard first (hostGuard(env): 404 { error: "not found" } under a Host not among DURABLE_HOSTNAMES, comma-separated, HOSTNAMES_VARIABLE, an entry's one * standing for part of one label, hostnameAdmitted, so the plane's per-deployment alias <slug>-*.<root> is admitted; unset or empty admits every host, a laptop's), then adoptOnAliasRequest, then the handler under withInvocation; dispatchFunction, healthFunction, relayFunctions ({ GET, POST }) and webhookFunction are asFunction over the react-router factories, so a hosted app's api/*.ts is one line each; admittedHostnames(env) is the pure read. The canonical paths stay the engine's: vercel.json's rewrites map them onto api/ (a dispatchPath option is DS-034). | | metrics.ts | vercelMetrics({ prefix?, metric?, startedMax? }) (ADR-0105 D17, DS-039): an Observer of the core's five boundaries as the platform's custom metrics through metric() of @vercel/functions (a no-op off the platform): durable.run.started and durable.run.finished (the count per key per invocation; workflow, outcome), durable.run.duration_ms on completed from the started moment kept per run in a map bounded at STARTED_MAX (10 000), durable.step.landed (the count per key per invocation; workflow, outcome, effect), durable.fact.emitted (the count per key per invocation; event), durable.fact.delivered (the count per key per invocation; listener, outcome); never an id in a tag; inside an invocation (withInvocation: every binding's handler, the tick among them) the counts are kept per distinct key on the invocation's own state and emitted once at its end (onInvocationEnd: the handler and every keepAlive task settled), the duration points first, one metric(name, count, tags) per key, inside the platform's METRIC_CALLS_MAX (100) calls per invocation (the points cut so the keys fit, the keys past the cap after them, and a cut never silent: one slot per kind cut is kept for durable.metrics.dropped (kind: points | keys, the value how many), so the key budget is the names times their tags' cardinality under a hundred per invocation, step.landed the widest at workflows × outcomes × effects; measured on the memory store, a tick resuming fifty runs of three steps and two facts is 56 calls where the per-boundary emit was 500), and outside an invocation each boundary emits as it lands (the value 1); metricNames(prefix), judgeMetricsPrefix (dotted lowercase, never vercel), flushCalls. Read with vc metrics durable.run.finished -a sum --group-by outcome --since 24h. | | shutdown.ts | installShutdown({ onShutdown?, log?, graceMs?, process?, now? }): the platform's SIGTERM (500 ms before scale-down) as one bounded moment, registered once per process (process.once; a later call adds its hooks to the same registration), every hook run in parallel under SHUTDOWN_GRACE_MS (400), one line platform.shutdown { hooks, ms, failed, timedOut }, nothing thrown and the process never ended here; onShutdown(hook), runShutdown, resetShutdownForTests. An attempt in flight is the lease's, never a hook's. | | pool.ts | attachPool(pool, { attach?, process?, … }): attachDatabasePool(pool) (the invocation held open until an idle client is ended, never a connection left on a suspended instance) plus pool.end() as a shutdown hook; the pool by shape (AttachablePool: end(), the driver's options/on), so pg stays a host's dependency and never this adapter's. Answers the pool for a one-line bind. |

Not here: ./next (the same bindings as Next route handlers; a NextRequest is a Request, so ./functions binds there too), nodePlatform() and inProcess().

Binding it#

// durable.config.ts
import { createDurable } from "@durable-sdk/core";
import { vercelPlatform } from "@durable-sdk/vercel";

export const durable = createDurable({
  // …
  platform: vercelPlatform({
    plan: "pro", // the plan the host runs under: the limit every route pins derives from its row (ADR-0066 D10; docs/durable/time.md)
    selfUrl: (env) => env.MY_APP_URL, // or a string; omit it for DURABLE_ALIAS_URL (the defaults below)
    cronSecret: (env) => env.CRON_SECRET, // the default
  }),
});

A host with no other boot check calls assertDurableEnv() once at boot: it throws naming every variable of DURABLE_REQUIRED_ENV (DATABASE_URL, CRON_SECRET, ADMIN_TOKEN) that is missing or empty, and nothing of what is set.

vercelPlatform() configures this process's adapter and answers the Platform the core takes (maxDurationS, wake, keepAlive, selfUrl, identity, selfTicks, subMinute), each member the same function the package exports by name, so a host may bind the object or the names. A second call replaces the configuration (a dev server's hot reload re-evaluates its config).

Option Default
plan The plan the host runs under ("pro", or { name, extended: true } for the Extended beta): the function limit every framework route pins derives from its row (@durable-sdk/vercel/plans, ADR-0066 D10), and the adapter's limits() answers the row to the time contract (D12). maxDurationS alone, for a host that declares no plan; with a plan, an explicit maxDurationS at or under the plan's maximum is admitted and one above it refused.
selfUrl A string, or (env) => string | undefined. Absent: DURABLE_ALIAS_URL, else on a production deployment (VERCEL_ENV=production) https://<VERCEL_PROJECT_PRODUCTION_URL>, else under role local alone (a laptop, vercel dev; ADR-0063 B14) the server's own http://localhost:<PORT> (localSelfUrl: PORT, else LOCAL_PORT_DEFAULT 3000), else empty. Never VERCEL_URL (Deployment Protection makes the generated URLs answer 401, and a preview must never kick production), and never the consumer's DURABLE_SELF_URL (below). Empty: no self-request is made, the cron does the work; a production deployment that resolves none logs deployment.alias_unresolved once, naming the variable.
cronSecret (env) => env.CRON_SECRET: the bearer the self kick carries (and, while wakeSecret answers nothing, the key the queue message is signed under, said once as platform.wake_secret.shared).
cronSecretPrevious (env) => env.CRON_SECRET_PREVIOUS: the cron bearer's previous value during a rotation (ADR-0076 D08, unit SOC-14), accepted by the cron bindings beside the current (every candidate compared in constant time, no early exit), never sent.
wakeSecret (env) => env.DURABLE_WAKE_SECRET: the key the queue message's mac is signed under, one key per purpose (SOC-14); unset, the cron secret signs in its place.
wakeSecretPrevious (env) => env.DURABLE_WAKE_SECRET_PREVIOUS: the wake key's previous value during a rotation, verified under by the consumer beside the current, never signed with.
env () => process.env, read at each use (never captured).
kickCoalesceMs KICK_COALESCE_MS (@durable-sdk/core/events): the sending side's coalescing window for the self kick, the route's window.
inline { concurrency: 4, backlogMax: 32, passesMax: WAKE_AGAIN_MAX (20) }: the inline scheduler's bounds.
queue { maxConcurrency: QUEUE_MAX_CONCURRENCY (8) } (ADR-0063 B15 half 1): the push consumer concurrency vercel.json's durable-wake trigger declares as maxConcurrency; read back as platform.queue.maxConcurrency and queueMaxConcurrency(), held by a host's guard, named by durable-sdk doctor --vercel when the trigger lacks it; a value that is not a positive integer is refused at vercelPlatform (durable.platform.queue.max_concurrency). Nothing coalesces on it yet (half 2 waits for the soak). false (ADR-0105 D09): the project has no queue; no wake is handed to send (no wake.queue_unauthorized probe), a delayed wake is the cron's (wake.left_to_cron { why: "no_queue" }), a timer inside the window is held by the self timer to the second (wake.timer_held { mode: "inline" }, since D09's amendment of 2026-10-30; at most TIMER_HOLD_MAX (64) timers held per process, the next the cron's, why: "hold_full"; beyond the window the cron minute's), subMinute() answers false (a schedule under a minute rides a delayed wake, the cron's here, so it is refused at the definition door); queueEnabled() reads it back.

The self URL is also the host the deployment marker is adopted from: a request whose host and x-forwarded-host agree on it proves the deployment current. On Vercel it is therefore the production alias, the URL the app is reached at, and it has a variable of its own, DURABLE_ALIAS_URL (ALIAS_URL_VARIABLE): the consumer's forward (below) reads DURABLE_SELF_URL for the opposite thing, the deployment's own origin, so one variable cannot feed both, and DURABLE_SELF_URL is never set on Vercel. On a laptop the two carry the same value, the local server, each under its own name, and neither needs setting: under role local the self URL is the server's own port (ADR-0063 B14).

roleFromVercel(env?) is the booting role (production | preview | local, from VERCEL_ENV: production, preview, anything else), the role healthLoader reports beside the host's environment name and the one a host binds as environment.role (ADR-0046 §D; §M step 7).

peersFromEnv({ members, self, env?, shorthand?, roles? }) (the ./env subpath, ADR-0046 §M step 7's PR 3) is the identity's peers resolver: for each member of durable.peers.json but self, the pair secret from DURABLE_PEER_SECRET_<NAME> (the core's peerSecretVariable) and the rotation's from DURABLE_PEER_SECRET_<NAME>_ACCEPT, wrapped as Secret<string>; when the file declares exactly two members and the named secret is unset, the host's one-peer shorthand ({ secret, url, variables? }, read by the host under its own names, both required; the URL overriding the file's); a secret shorter than 32 characters, or a shorthand URL that is not absolute http(s), drops the peer with one relay.peer_misconfigured { name, variable } line per process and never the value; a booting role outside roles (["production"] by default, §D's rule; EVERY_ROLE for a host whose own rule gates) answers nothing. The file's own fields are code: members are asserted first (the core's assertPeerDeclarations; PeerMember is its PeerDeclaration) and a bad file throws PeerMisconfigured naming the member and the rule.

The modes (DURABLE_WAKE)#

Read by wakeMode() alone, never by the engine (it asks selfTicks()).

  • self (unset, empty or self): one GET <selfUrl>/jobs/dispatch?kick=1&partition=… with the cron bearer per committed fact, coalesced per process to the leading edge of a kickCoalesceMs window and one trailing kick at its end, a plain ?kick=1 carrying the stamp of the claim the window's kick was answered with (x-durable-kick-claim back as x-durable-kick-coalesced-on), so it claims on the row and ticks at once; at most two self-requests per process per window. A wake for a moment still ahead (a backoff's notBefore) is left to the cron. The dispatcher keeps its half tick and its trailing edge (selfTicks() true); no wake inside the minute is held (subMinute() false: a schedule under a minute is refused at the definition door, ADR-0076 FP-036).
  • none: no wake; the cron tick and the half tick are the transport (a laptop, a soak of the fallback). subMinute() false.
  • queue (on a production deployment alone, else wake.queue_refused once and self): one send("durable-wake", { v: 1, signal, deploymentId, mac }) per wake, keyed per attempt and, for a delayed wake, its moment (wakeKey, :at<epoch s> of notBefore since FW-047; hashed past 256 characters), retained WAKE_TTL_S past its delay, a delayed wake sent with delaySeconds and none past WAKE_MAX_DELAY_S; mac is an HMAC-SHA256 under the cron secret over wakeMacInput (the version, the deployment, the kind, the partition, the forwarded id), which the consumer verifies. A 401/403 turns the process back to self for its life; a 502 naming no consumer or any 503 for one QUEUE_RETRY_AFTER_MS window; anything else is dropped and the cron covers it. selfTicks() false; subMinute() true on a plan whose cron runs every minute (Pro, Enterprise, or no plan declared), false on Hobby: a schedule's slots inside the coming minute ride the queue as delayed wakes (ADR-0076 FP-036).
  • inline (production alone, else wake.inline_refused once and self): the committing process drains the wake's partition itself under keepAlive (runPartitionTick from @durable-sdk/core/events), behind the marker adoption in flight; one drain per partition at a time (a wake for a draining partition makes it run once more, at most passesMax ticks), at most concurrency drains at once and backlogMax partitions waiting (a waiting drain starts in the context of the request that queued it: its own deadline, its own waitUntil); a wake past the bound, and every delayed wake, rides the queue while it is open and is the cron's otherwise, but a timer whose moment passed is kicked at once whatever the queue answered. selfTicks() false; subMinute() as under queue (true on a plan whose cron runs every minute, false on Hobby).
  • queue: false (an option, not a mode; ADR-0105 D09): under any mode the adapter never calls the queue's send. inline with it is what a hosted app runs: an immediate wake drains in process, a delayed wake is the cron minute's (wake.left_to_cron { why: "no_queue" }), a timer inside the window is held by the self timer to the second as under self (selfTimer, wake.timer_held { mode: "inline", held }; ADR-0105 D09 as amended 2026-10-30), a timer whose moment passed is kicked at once, and subMinute() is false, so a schedule.every under a minute is refused at the definition door rather than degraded silently. Every hold counts against TIMER_HOLD_MAX (64 held timers a process, every mode alike): a held timer keeps its invocation alive for its delay, so past the cap a timer is the cron minute's (wake.left_to_cron { why: "hold_full", held, max }) and a hold that fired frees its place; the cap is on platformLimits() (wake.timerHoldMax) and docs/durable/time.md.

Every outcome is a log line through the core's log, never a throw into the engine: wake.queue_refused, wake.inline_refused, wake.unknown_mode (once per process each), event.dispatch_hold_off (the first suppressed schedule), dispatch.kicked / dispatch.kick_failed, wake.coalesced, wake.left_to_cron (why: no_timer, past_max_delay, queue_closed, no_queue, queue_fallback, backlog), wake.queued, wake.deferred, wake.duplicate, wake.queue_unauthorized, wake.queue_unavailable, wake.send_failed (the wake then falls back as a refusal does), wake.inline_failed, wake.inline_backlog, wake.inline_capped, deployment.adopt_failed.

The adoption (rule 7)#

A partition wake served by a deployment the marker RuntimeSetting['durable.deployment'] does not name dispatches nothing, and the cron tick writes the marker; so a production deployment adopts it, off the response path under keepAlive, on its first request through the production alias (adoptOnAliasRequest(request), the first statement of every alias-facing handler) or its first cron minute (adoptOnCronRequest(), after the bearer check), once per process; a failed attempt and a schema refusal are retried by the next such request; an inline drain waits on adoptionSettled() before its first tick.

The consumer (@durable-sdk/vercel/consumer)#

The Vercel Queues consumer of the durable-wake topic (ADR-0045 §2 "The consumer", step 4, placement (a) thin). A host's root push function is the whole of it:

// api/durable/wake.ts (a root api/** file, built by @vercel/node beside the app)
import { createConsumer } from "@durable-sdk/vercel/consumer";

const consumer = createConsumer({ cronSecret: (env) => env.CRON_SECRET });
export const POST = consumer.POST;

with vercel.json naming the file (functions["api/durable/wake.ts"]: runtime: "@vercel/node@<exact version>", since a framework preset ignores @vercel/node for a root api/ file; maxDuration above FORWARD_TIMEOUT_MS; experimentalTriggers: [{ type: "queue/v2beta", topic: "durable-wake", maxDeliveries: 1 }]), @durable-sdk/vercel in the root package.json (a root file never relies on the workspace's hoisting), and the package's dist built before the host's build on every environment (the builder traces dist/consumer.js and dist/mac.js, the Queues client and nothing else; an offline vercel build on 2026-09-27 recorded the trace: no file of the host, of the core or of Prisma).

createConsumer(options) answers handle (never throws), retry (always { acknowledge: true }: Postgres owns the retries) and POST (the handleCallback of @vercel/queue over the two). handle parses the message's ids (parseMessage), acknowledges a message of another deployment without a forward (wake.stale, once per publisher), verifies the mac under the cron secret in constant time and acknowledges a forgery without a forward (wake.unsigned, once per process: the consumer trusts the message, never the transport), then forwards GET <selfUrl><dispatchPath>?wake=<partition>&outboxId=<id> with the bearer, x-vercel-protection-bypass from VERCEL_AUTOMATION_BYPASS_SECRET and x-deployment-id under Skew Protection, waiting at most FORWARD_TIMEOUT_MS (wake.forwarded, wake.forward_refused, wake.forward_timeout, wake.forward_failed; wake.no_self_request when a variable is missing; wake.malformed; wake.ignored for a timer). Log lines carry ids and a partition string only; an error's text is scrubbed of a bearer and the secrets (scrubError).

Option Default
cronSecret (env) => env.CRON_SECRET: the bearer the forward carries (and the mac's verify key while wakeSecret answers nothing).
cronSecretPrevious (env) => env.CRON_SECRET_PREVIOUS: the cron bearer's previous value during a rotation (SOC-14), a verify key beside cronSecret while no wake key is set.
wakeSecret (env) => env.DURABLE_WAKE_SECRET: the key the mac is verified under (one key per purpose, SOC-14); unset, the cron secrets verify and platform.wake_secret.shared is said once per consumer.
wakeSecretPrevious (env) => env.DURABLE_WAKE_SECRET_PREVIOUS: the wake key's previous value during a rotation, verified under beside the current (verifyWakeAny, every candidate in constant time).
selfUrl DURABLE_SELF_URL (a local server), else https://<VERCEL_URL>: the deployment's own host, never the production alias (which may point elsewhere during a promote) and never DURABLE_ALIAS_URL; the bypass header covers its protection.
dispatchPath DEFAULT_DISPATCH_PATH, /jobs/dispatch.
env process.env.
fetch The global, read at each forward (a test may stub it after the root function made its consumer).
log One JSON line per event on console.log.
now Date.now.

The route bindings (@durable-sdk/vercel/react-router)#

Five factories, each answering a handler of the structural shape ({ request }) => Promise<Response> (no react-router import):

// app/routes/jobs.dispatch.tsx: the dispatch tick, every entry
import { durable } from "../durable"; // by name: a bare import stays in the client bundle
import { dispatchLoader } from "@durable-sdk/vercel/react-router";
export const config = { maxDuration: 800 }; // a literal: the preset reads it at build time; pnpm gen:platform writes it from the plan row
export const loader = dispatchLoader({ durable });

// app/routes/jobs.<name>.tsx: any other cron target a host declares (a keyed
// run per slot declares a `schedule` on its definition instead, ADR-0050
// decision 2, and a run over more than a function holds is a batch step
// that parks, ADR-0052 decision 2: neither needs a route)
import { cronLoader } from "@durable-sdk/vercel/react-router";
export const config = { maxDuration: 800 };
export const loader = cronLoader({ run: () => runNightlyExport() });

// app/routes/health.tsx: the public liveness probe (no config: it runs no framework work)
import { durable } from "../durable";
import { healthLoader } from "@durable-sdk/vercel/react-router";
export const loader = healthLoader({ durable });

// app/routes/internal.relay.tsx: the relay receiver (ADR-0046 step 7, PR 5)
import { durable } from "../durable";
import { relayRoute } from "@durable-sdk/vercel/react-router";
export const config = { maxDuration: 800 };
export const loader = relayRoute({ durable }).loader; // two bindings: the plugin refuses
export const action = relayRoute({ durable }).action; // to remove a destructured export

// app/routes/webhooks.orders.tsx: an inbound webhook (ADR-0051 amendment 2026-09-28)
import { durable } from "../durable";
import { webhookRoute } from "@durable-sdk/vercel/react-router";
import { verifyOrders, toFacts, record } from "../lib/webhooks/orders.server"; // the host's
export const config = { maxDuration: 800 };
export const action = webhookRoute({
  durable,
  verify: verifyOrders,
  toFacts,
  record,
});

dispatchLoader({ durable }) is the whole of the dispatch tick's route: the bearer check, a partition wake (?wake=<partition>&outboxId=, the partition tick; 400 for an empty partition, 503 when the schema probe refused), a lane (?lane=n: await durable.load() before dispatchOutbox( with the core's dispatchSettings()), a kick (?kick=1, claimed through the settings row, 204 coalesced with the claim headers and a trailing edge unless it is one itself), the whole tick (503 when refused; the half tick scheduled after the cron's tick alone, the platform's selfTicks deciding). cronLoader({ run }) is the bearer check, then adoptOnCronRequest() (rule 7's marker, after the check and never before), then Response.json(await run(args)). Both answer 401 { error: "Unauthorized" } without the bearer; the bearer is the option's cronSecret over the option's env, each defaulting to the platform's (vercelPlatform({ cronSecret, env })), and during a rotation the previous value beside it (cronSecretPrevious, CRON_SECRET_PREVIOUS; SOC-14). healthLoader({ durable }) is public: adoptOnAliasRequest(request) first (a release's first probe through the alias is the new deployment's first chance to adopt the marker), then { ok: true, sha, env, time, environment: { name, role } } with Cache-Control: no-store and no database on its path: sha from VERCEL_GIT_COMMIT_SHA (or the option's sha(env), null when unset), env the raw VERCEL_ENV or "local", environment.name the host's durable.environment.name (null when none was bound) and environment.role from roleFromVercel. The probe never depends on the adoption's answer. Since ADR-0046 §M step 7 (PR 3) environment also carries peers, the names of durable.relay.peers() (names only: no URL, no secret), so the loader takes Pick<Durable, "environment" | "relay">. relayRoute({ durable, now? }) (ADR-0046 §M step 7, PR 5) is the relay receiver's route, { loader, action }: each handler hands the request to adoptOnAliasRequest first (a peer posts to this app's alias, so a fresh deployment whose first request is a batch adopts the marker before the inline drains its copies wait on it), the loader and any method but POST answer 405 { error: "POST only" }, and the action delegates to the core's receiveRelay (@durable-sdk/core/events): the signature against every configured peer, the timestamp, the schema probe, the envelope, the sequence rule, the landing through the bound store, the wake, the contact rows and the ack { accepted, duplicates, rejected, v: 2, lastSeq, acceptedIds, heldIds }. It takes the whole Durable (the peers, the identity, the store, the partition rule, the catalog, the schema probe and the wake); now is a clock for the tests. webhookRoute({ durable?, verify, body?, toFacts, record?, methods? }) (ADR-0051 amendment 2026-09-28; durable optional since ADR-0051 "As landed (the strains)": absent, the route reads the instance bound to the process or to the ambient scope of the call at each request, so a page with no host exports the route directly, and a host whose route file must reach its barrel by name, the client-bundle rule, hands it) is an inbound webhook's action, in this order: the adoption first, exactly as relayRoute; the method (POST alone unless methods says otherwise, else 405 { error: "<methods> only" }); verify(request), the host's check of the provider's signature (one function per provider), answering { ok: true, context }, { ok: false, status, body? } (answered as it is, no fact) or throwing a Response (returned as it is) or anything else (logged webhook.verify_failed { route }, answered 500 with an empty body: not the provider's refusal but a signed delivery the host could not read, so never a 401); body (ADR-0076 SOC-18, input schemas at every door): the host's schema of the provider's body as toFacts reads it, { schema, of, record? } (a safeParse, zod's or any; what of the verified context to judge, the parsed body or payload; the host's audit row of a refusal), judged here, after the signature and before any field is read: a body off its shape is 400 { error: "invalid body", field, message } naming the first issue's field ("" at the root), logged webhook.body_refused { route, field, message }, recorded through the option's own record (its throw webhook.record_failed, the 400 standing), no fact emitted and the route's record not called; the schema is the fields the route reads, typed, with the rest of the provider's body admitted (z.looseObject); toFacts(context), the host's reading of the delivery as WebhookFact[] (a catalog name and its payload, typed together over EventPayloads), null or [] for nothing, or { ignored: reason } (logged webhook.ignored { route, reason }); each fact emitted in order through the core's emit under the instance handed (withDurable: the catalog's key, so a redelivery collapses on the first row); then record?.(context, facts), the host's audit row, whose throw is logged webhook.record_failed and never fails the answer (the fact is the receipt; a delivery with no fact writes its row inside toFacts, where a failure is the 500 below); then an empty 200. A throw of toFacts or of the store is left to the caller (the fact was not written; the provider redelivers; the rows written before a mid-list failure stand, and the redelivery collapses on them and writes the rest). route is the request's path. The binding names no provider and no fact.

The platform bindings (ADR-0105 D17, DS-039)#

What a host binds beside the engine, each read off the platform's own promises as its skills state them (Fluid Compute, the 500 ms stop signal, custom metrics):

import { poolConfig } from "@durable-sdk/postgres";
import {
  attachPool,
  installShutdown,
  vercelMetrics,
} from "@durable-sdk/vercel";

const POOL_MAX = 5; // the tier's number on the platform: Free 5, Pro 7, Enterprise 20
const pool = attachPool(
  new pg.Pool({
    ...poolConfig(process.env.DATABASE_URL!, {
      max: POOL_MAX,
      applicationName: "durable-app",
    }),
    idleTimeoutMillis: 10_000,
    connectionTimeoutMillis: 10_000,
  }),
);
installShutdown(); // your own hooks: installShutdown({ onShutdown: [flushSink] })
export const durable = createDurable({ /* … */ observers: [vercelMetrics()] });
  • attachPool is the platform's attachDatabasePool plus the pool's end() under SIGTERM; the pool is taken by shape.
  • installShutdown registers the one SIGTERM listener per process and runs every hook together under a 400 ms grace (inside the platform's 500), saying one line; it never throws and never ends the process.
  • vercelMetrics emits the six durable.* metrics with bounded tags; a throwing emitter reaches no caller; the prefix is judged. Inside an invocation the counts are aggregated and emitted once at its end, one call per distinct key (the duration points first), so a busy tick stays inside the platform's hundred metric() calls per invocation.

What the engine never assumes of the platform (the docs' platform page): a cron on a preview, state in a process, a second region, a body over 4.5 MB, an error page of its own for a platform fault. Request cancellation is never enabled on an engine route (the guard platform/no-cancellation-on-engine-routes) and a template never carries regions (platform/template-carries-no-regions).

Workspace mechanics#

exports["."] points types at src/index.ts and default at dist/index.js while the package is private: the app and the tests resolve the source through the root tsconfig.json paths and vite-tsconfig-paths. npx durable-sdk:build at the root builds it beside the Postgres package and the CLI; publishConfig replaces the exports with the dist pair on publish. pnpm --filter @durable-sdk/vercel check runs typecheck, lint, build and pack:check (publint and attw on the packed tarball); pnpm check:sdk runs it for every SDK package, as CI's durable-sdk-checks matrix does.

The relay's sending side is the core's (relayTickTasks(), @durable-sdk/core/events, ADR-0046 §M step 7 PR 7; the one sender since the cutover of PR 10): this package binds no send and reads nothing of the relay but the peers' secrets (peersFromEnv).

In the first host, app/lib/platform.server.ts is the one vercelPlatform({ plan: PLAN, cronSecret: (env) => env.CRON_SECRET }) binding (the limit derives from the plan row, ADR-0066 D10; the self URL is the default, DURABLE_ALIAS_URL, set on both Vercel projects to the app's URL) plus a named re-export list, app/lib/deployment.server.ts a named re-export list that loads the host's engine barrel (app/durable, so the core is configured before adoptDeployment reads it from a route bundle that loads no workflow) and then the platform stub first, app/lib/routes.server.ts a named re-export list of ./react-router (the barrel first) that the cron routes and /health import, and durable.config.ts binds the names; nothing else under app/ imports this package by its root or a subpath (the invariants guard), and the root function api/durable/wake.ts re-exports ./consumer (scripts/vercel-build.sh runs npx durable-sdk:build on every environment for its dist).