Deploying
Options, progress, readiness and capabilities.
import { Effect } from "effect"
import { Deploykit } from "@deploykit/core"
const publish = Effect.gen(function* () {
const deploykit = yield* Deploykit.Deploykit
return yield* deploykit.deploy(appId, artifact, options)
// or straight from a directory:
// return yield* deploykit.deployDirectory(appId, "./build", options)
})deploy returns once the host has created the deployment and given it an id. The build
usually carries on after that, so wait for it.
What happens during a deploy
- Validate. Paths, sizes and options are checked. Unsupported options fail here, before any network call.
- Hash. Each file is hashed the way the host expects.
- Negotiate. deploykit asks the host which files it already has, and skips those.
- Upload. Missing files are uploaded in parallel, within the memory and disk budgets.
- Create. The host creates the deployment. This is the one step that's never retried.
Options
These work on every provider.
| Option | Type | What it does |
|---|---|---|
target | "production" | "preview" | Where to deploy. Defaults to production. |
onProgress | (event) => void | Progress updates. See below. |
signal | AbortSignal | Cancel the call. Promise API only; see Lifecycle. |
Provider-specific options are on the Vercel and Cloudflare pages. A provider that doesn't support an option rejects it before uploading anything, rather than ignoring it.
Progress
The callback returns an Effect.
const publish = Effect.gen(function* () {
const deploykit = yield* Deploykit.Deploykit
return yield* deploykit.deploy(appId, artifact, {
onProgress: event => Effect.logInfo("deploy progress", event)
})
})| Event | Fields | Sent |
|---|---|---|
Hashing | done, total | While hashing files |
Uploading | done, total, bytes | As the host confirms uploads |
Throttled | retryAfterMs? | When the host rate-limits |
Created | deploymentId | Once, when the deployment exists |
bytes counts only bytes the host confirmed, excluding files it already had and repeated
attempts. The callback must be quick: each call is cut off after 100 ms, and its errors are
ignored. Progress isn't a receipt. Save the Deployment that deploy returns.
Waiting until it's ready
A deployment goes pending → deploying → deployed or failed. Poll getDeployment
until the status is final.
import { Effect, Schedule } from "effect"
import { Deploykit, Provider } from "@deploykit/core"
const waitUntilReady = (appId: string, deploymentId: string) =>
Effect.gen(function* () {
const deploykit = yield* Deploykit.Deploykit
return yield* deploykit.getDeployment(appId, deploymentId).pipe(
Effect.repeat({
until: d => Provider.isTerminal(d.status),
schedule: Schedule.spaced("1 second")
}),
Effect.timeout("5 minutes")
)
})A failed deployment may have a reason from the host.
Checking it serves
deployed means the host finished, not that the URL answers yet. waitUntilServing polls the
URL until it returns a 2xx, for up to 60 seconds.
import { Platform } from "@deploykit/core"
const check = Platform.waitUntilServing(ready.url!, { timeoutMs: 60_000 })| Option | Default | What it does |
|---|---|---|
timeoutMs | 60000 | Overall deadline, including every request |
accept | 2xx | (status) => boolean for success |
fetch | global fetch | Custom transport; must honour the abort signal |
It resolves with the status it accepted, or fails with NotServingError (with the last status
seen and waitedMs). It doesn't follow redirects, so a login page never counts as success. After
this, run your own checks: only you know what "working" means for your app.
Capabilities
Providers differ. Check before offering a feature:
const caps = Effect.map(Deploykit.Deploykit, deploykit => deploykit.capabilities)| Field | true means | Vercel | Pages |
|---|---|---|---|
deferredActivation | You can stage now and go live later | Yes | No |
reconciliation | You can recover a lost response | Yes | No |
previewDeployments | target: "preview" works | Yes | With previewBranch |
adoptByName | findAppByName works | Yes | Yes |
accessModes | Which access settings work | All | None |
listDeployments, deleteDeployment and rollback also have capability flags.
The current HTTP adapters implement them; a custom provider can omit them. See
deployment management.
Calling something unsupported fails with UnsupportedError.
Last updated on