Skip to Content
Appwright
Technical Overview

Cloudflare Workers

How Bound builds on Workers for Platforms, and how your workers are built and run

Bound is built on Workers for Platforms, Cloudflare’s toolkit for platforms that run their users’ code. This page explains the pieces and — most importantly — how your code, credentials, and data are kept isolated and safe.

The pieces

Dispatch namespace (one per shop)

Every shop that installs Bound gets its own dispatch namespace — an isolated container for that shop’s workers, named after the store’s globally unique myshopify.com domain. Your workers exist only as scripts inside your shop’s namespace; no other merchant’s code, secrets, or usage data ever shares it. Namespaces are created on install and deleted on uninstall.

Dispatcher (one per shop)

Each namespace has a platform-managed dispatch Worker (named <store>--bound-dispatcher) — the single front door for every request to any of your workers. It never appears in your dashboard and can’t be edited. For each incoming request it:

  1. Routes on the first URL path segment — the worker’s handle.
  2. Meters the run against your shop’s monthly run limit, returning a 429 when the cap is spent. (Metering deliberately fails open on infrastructure errors — a platform blip never takes your storefront down.)
  3. Looks up the worker’s configuration — its enabled-secret allowlist and pinned API versions — fresh from the platform database on every request, so changing a worker’s secrets or API versions takes effect immediately with no redeploy.
  4. Builds the worker’s capabilities: only the secrets explicitly enabled for that worker (platform-owned secrets are withheld always), plus authenticated Shopify API clients pinned to that worker’s API versions.
  5. Dispatches the request to the worker and returns its response.

Errors are collapsed before they reach callers: an unknown worker is a bare 404, anything else a bare 500 — internal details never leak to the HTTP response.

User workers (yours)

The workers you write are scripts deployed inside your shop’s namespace. They hold no bindings of their own — no environment variables, no secrets, no database access. This is a deliberate safety property: there is nothing in a worker’s environment to leak or escape into. Every capability arrives at runtime through this.ctx.props, vetted and assembled by the dispatcher per request.

How your worker is built

You only ever write the body of a fetch handler — the code that receives a request and returns a response. At deploy time, Bound wraps that body in a standard Cloudflare module template: a WorkerEntrypoint class whose fetch method your code becomes. That wrapper is what gives your code its this — the execution context with this.ctx.props (your capabilities) and this.ctx.waitUntil() — and it’s how the dispatcher calls your worker with exactly the right props for that request.

No merchant code is modified beyond being placed in the template, and nothing else is injected. Each deploy also stamps the worker with a 30-second per-invocation CPU limit — uniform across all plans — so one runaway worker can’t consume shared compute.

Your source is versioned separately from the deployed script: every save stores an immutable snapshot, which is what version history, preview, and restore are built on.

How Shopify API access stays safe

Workers call Shopify through RPC capability stubs (this.ctx.props.admin / this.ctx.props.storefront) that execute inside the dispatcher, not inside your worker:

  • Admin API — the dispatcher authenticates with Shopify’s client credentials grant, signing a short-lived (60-second) ES256 JWT client assertion with a platform-held private key and exchanging it for an access token. Tokens are cached briefly (evicted before expiry, re-minted on rejection) and never enter worker code — your worker only ever holds the RPC stub. No per-shop admin OAuth token is stored for this path at all.
  • Storefront API — a non-expiring public Storefront token (scoped to the app’s catalog-level unauthenticated_* permissions) is stored as a platform secret on the dispatcher and likewise never reaches worker code.

Because API versions are pinned per worker and read per request, the same dispatcher serves every worker at its own pinned versions simultaneously.

Lifecycle

  • Install — the namespace, dispatcher, platform secrets, and Storefront token are provisioned automatically (all idempotently, so re-auth re-verifies rather than duplicates).
  • Redeploys of the dispatcher (for platform updates, triggered from Settings → Refresh Dynamic Dispatcher) preserve your secrets and never touch your workers.
  • Uninstall — the dispatcher (and its secrets), the namespace, and every worker in it are deleted immediately; remaining stored records are erased when Shopify’s mandatory data-protection webhook follows. See the privacy policy for retention detail.