Skip to content

Instance overview

An instance is a private Scwrap installation in one Cloudflare account - a release Worker that runs each Release in its own sandbox, a controller Worker and two R2 buckets - built by @scwrap/platform-cloudflare.

An instance is where Releases run. It is private: one Cloudflare account, one hostname, a run token for callers and a deployer token for deploys. @scwrap/platform-cloudflare is the package that implements it.

The parts ​

PartWhat it isJob
Release Workerscwrap-instance-<stage>Serves the catalog, runs Worker releases, checks every item, stores results and serves the MCP server. It serves no pages; any other GET answers 404 or a redirect (Other paths). It has no route of its own.
Controller Workerscwrap-instance-<stage>-controller, owner of the hostnameIts Durable Object accepts Releases, serializes deploys and activates new release Worker versions with the instance's Cloudflare token. Every other request goes on to the release Worker.
Run ownerA Runner Durable Object named run-<resultId>, one per RunExecutes one Run after its caller has gone, stores its items and final record, ends the Run at its maximum duration, marks the Run failed if it dies, and stops the Browser Use sessions the Run left open.
Idempotency keeperA Runner Durable Object named idempotency-<hash>, one per run token name, Scraper and Idempotency-KeyHolds the first Run's resultId and input digest for 24 hours, so a repeat request returns that Run (Idempotency-Key).
Results bucketA private R2 bucketHolds every Run's record, items and listing index. A lifecycle rule deletes each object when the instance's result retention runs out, 30 days after it was written by default.
Artifacts bucketA private R2 bucketHolds Release artifacts and platform manifests. Nothing expires.

There is nothing else. An instance has no database, no queue and no scheduling.

What happens in a Run ​

  1. A caller sends POST /scrapers/<id>/run with the run token and a JSON input.
  2. The Worker looks up the installed Release for that ID, hands the Run to a new Run owner, which writes a result record with status running, and answers 202 with that record.
  3. The Run owner runs the Release's Stream from its alarm, in the Release's own Dynamic Worker sandbox (Each Release in its own sandbox).
  4. The sandbox checks each item against the Definition's output schema, and the Run owner writes it to R2.
  5. When the Stream ends, the Run owner writes the final record, completed or failed.

Every Run starts as soon as it is accepted, in its own Run owner: there are no slots and no queue to wait in. A Run lasts at most its Release's maximum duration, 10 minutes unless the Release sets maxRunDuration, and never more than 14 minutes. At the limit the Release's sandbox stops the Stream, which closes its scope and with it the Run's browser session, and the Run owner keeps the items checked so far and ends the Run failed with RunTimeout (Run duration).

The caller reads the record by result ID until it is no longer running, then reads the items. Leaving does not stop the Run, and neither does a deploy: a Run active during one finishes on the version it started on (Runs during a deploy). A Run whose owner dies ends failed with the error Run abandoned: its owner stopped before the Run ended.

What an instance does not have ​

Knowing the limits saves time.

It has noSo
Triggers or schedulesA Run starts only when a caller starts it. Scheduling belongs to the caller, by design (Scheduling Runs).
Completion webhooksA finished Run is not pushed to anyone, by design (Non-goals). The caller reads the record by result ID.
Rate limiterEvery authenticated request is served until a Cloudflare limit stops it (Rate limits).
Capabilities of its ownA Release provides every Capability itself.
User accountsAccess is by bearer token: the default run and deployer tokens reach everything, and named tokens give each caller or deployer its own, optionally limited to some Scrapers. Every result record names the run token that started it in tokenName.

Known gaps lists everything an instance does not do yet.

Production ​

StackScwrapInstance/production
Workerscwrap-instance-production
URLhttps://scwrap.j4k4.dev
MCPhttps://scwrap.j4k4.dev/mcp
Deployed byCI, on every push to main, after the tests pass
ReleasesThe example Scrapers from instance-scrapers.ts, plus the Releases other repositories deploy to it

In this section ​

PageRead it for
HTTP APIEvery route, its request and its answers.
MCP serverThe tools an agent gets.
TracingWhere a Run's spans go and how to find its trace.
Deployment serviceHow the instance installs Releases and recovers from interrupted deploys.
CredentialsThe front desk that holds vendor credentials and hands Releases capabilities under the owner's grants.
InfrastructureThe Stack, its bindings and credentials, and how to set up a new instance.
Known gapsWhat an instance does not do yet.

Source ​