← Back to Pull requests

Add R2 buckets to workerd #8507

Closed
unknown closed this pull request without merging on Nov 19, 2026 15:24 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 22:48 UTC
Author

workerd has no R2, so a Worker with an r2Bucket binding only runs under Miniflare or an embedder's own implementation. This adds R2 to standalone workerd and to a cluster.

R2 is a bundled Worker, /workerd/r2.js, as KV is: it serves the protocol the existing R2 binding already speaks, so the binding is unchanged, and the bucket is named in the binding's props. It stores each R2 object as one object under its own key in a bucket service, which gains a small S3-like HTTP API (HEAD, ranged GET, list, conditional writes, multipart). In a cluster that is the cluster's S3 or Cloud Storage bucket, so S3 and GCS tools read a bucket directly; without one, a local store on disk that several processes can share. There is no index.

(name = "PHOTOS", r2Bucket = (name = "r2", props = (json = "{\"bucket\": \"photos\"}"))),
(name = "r2", worker = (
  modules = [(name = "r2.js", bundled = "/workerd/r2.js")], compatibilityDate = "2026-01-01",
  bindings = [(name = "BLOBS", service = "r2-blobs")])),
(name = "r2-blobs", bucket = (path = "r2")),

// wrangler.jsonc, then `workerd serve --experimental`
{
  "name": "app",
  "main": "index.js",
  "r2_buckets": [{ "binding": "PHOTOS", "bucket_name": "photos" }]
}

Values stream both ways. A put is hashed as it is read and written only if its checksums pass. Miniflare's R2 tests pass against it (cloudflare/workers-sdk#17019, draft). Where a plain object store can't be R2, listed at the top of r2.js:

  • objects over 8 MiB get a multipart etag, and their onlyIf isn't fenced

  • part etags are their MD5; aborting an unknown upload succeeds

  • on S3, customMetadata is limited by S3's 2 KB of user metadata

  • a listing that includes metadata is a HEAD per object

  • uploads cut off mid-stream are left for the bucket's lifecycle rule
  • Not yet: more than one part in flight (one stream tops out around 12-15 MB/s), and an S3-compatible endpoint.

    Diff: 240 lines (+180 / -60) across 3 files Reviewer: piscisaureus Review duration: 3876m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 240 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.328
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #8507"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.7% (MEDIUM) · Higher = larger blast radius
    38.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.3% · Safe to merge
    15.3%