GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — hosted-worker user-do: KV and blob PUT buffer the whole request body before the storage ceiling check · Issue #11332 · developing-today/code

hosted-worker user-do: KV and blob PUT buffer the whole request body before the storage ceiling check #11332

New issue
Copy link
New issue
Copy link
Closed
#11336
Closed
hosted-worker user-do: KV and blob PUT buffer the whole request body before the storage ceiling check#11332
#11336
Copy link
Labels
app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

Description

@dezren39
dezren39
opened on Nov 17, 2026
Issue body actions

Evidence (origin/main ccb195b)

  • `pkgs/id/hosted-worker/src/user-do.ts:291-300` (KV PUT): `const value = await req.text();` runs before any size check. The byte delta is computed only afterwards, in `this.assertWritable(new TextEncoder().encode(value).byteLength - priorBytes)` at `:295`.
  • `pkgs/id/hosted-worker/src/user-do.ts:237` (blob PUT): `const bytes = new Uint8Array(await req.arrayBuffer());` has the same order. `assertWritable` runs at `:246`.
  • `assertWritable` (`:135-146`) checks the storage ceiling only. Nothing in `hosted-worker/src` caps the request body size (grep for content-length, 413, too_large and bodyLimit finds only the storage 413 in `assertWritable`).

Result: a write that is already over the ceiling is still fully buffered into the Durable Object's memory before it is refused with a 413. A body larger than the DO's memory limit would fail inside the isolate rather than return the documented `ceiling_exceeded` response.

Not yet reproduced at runtime. The claim is about the code path, not a measured OOM.

Why it matters

The ceiling is documented as a fail-closed guard for writes. The guard runs after the most expensive step, so an oversized write can crash the DO instead of being refused cleanly. The user then gets an opaque error and the DO may reset.

Fix shape

  • Reject early from `Content-Length` when it is present and already exceeds the remaining headroom (`ceiling - usage`), before reading the body.
  • For bodies without a length, read through a size-capped reader that stops at the remaining headroom plus one byte, then returns `ceiling_exceeded`.
  • Keep the existing `assertWritable` check as the authoritative delta check.

Acceptance criteria

  • A PUT to `/v1/kv/:key` or `/v1/blobs` whose declared length exceeds the remaining headroom returns 413 `ceiling_exceeded` without reading the body.
  • A chunked PUT larger than the headroom stops reading at the cap and returns the same 413.
  • Existing under-cap writes and overwrite deltas behave as before.
  • A test covers the early reject and the chunked cap.

Dedupe

Searched open and closed issues for "user-do KV body", "request body size limit hosted-worker" and "user-do": no matching issue or open PR. Related but different: #6880 and #2791 (cloudflare-export numeric handling) and #3000 (aggregator regex), none of which touch this path.

Queue: `repo-queue` is not available in this environment, so no queue item was enqueued. Coverage needs a follow-up pass.

Activity

  1. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 17, 2026
  2. developing-today commented on Nov 17, 2026

    @developing-today
    developing-todayBot
    on Nov 17, 2026 – with developing.today
    Contributor
    More actions

    CODE-4113

  3. developing-today
    added
    status:in-review
    on Nov 17, 2026
  4. dezren39
    added 3 commits that reference this issue on Nov 17, 2026

    hosted-worker: kv shrink not refused when usage is over ceiling (#11332)

    cab8f68

    hosted-worker: revert max() headroom; shrink over cap is refused by a…

    48878de

    Merge pull request #11336 from developing-today/sweep/11332-user-do-b…

    c4a5fb5
  5. dezren39
    closed this as completedin #11336on Nov 17, 2026
  6. dezren39 commented on Nov 17, 2026

    @dezren39
    dezren39
    on Nov 17, 2026
    MemberAuthor
    More actions

    Fixed in #11336 (merged as a merge commit).

    • KV PUT now computes headroom (ceiling - usage + prior value bytes) before reading the body. A declared Content-Length over headroom returns 413 ceiling_exceeded without reading. A chunked body is read through a capped reader that stops at headroom.
    • assertWritable remains the authoritative check. Under-cap writes and overwrites are unchanged.
    • Blob PUT is deliberately not changed: it hashes first because a re-upload of an already-referenced blob has zero storage delta and must stay allowed at cap. The buffering there is a follow-up if it matters.
    • Tests: two new cases in test/usage.test.ts. node --test over routing, blobs, usage and currency: 22/22 pass.

    Not reproduced at runtime; this is from the code path.

  7. developing-today
    added
    status:done
    and removed
    status:in-review
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.