Skip to content

[miniflare] Fix Buffer type not accepted for D1 blob bindings#12514

Open
ascorbic wants to merge 4 commits intomainfrom
fix/buffer-devalue-serialization
Open

[miniflare] Fix Buffer type not accepted for D1 blob bindings#12514
ascorbic wants to merge 4 commits intomainfrom
fix/buffer-devalue-serialization

Conversation

@ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Feb 10, 2026

Fixes #5771.

The ArrayBufferView devalue reducer serialises typed arrays by constructor name. Node.js Buffer extends Uint8Array, so ArrayBuffer.isView() matches it and serialises ["Buffer", ...]. On the workerd side, the reviver fails because:

  1. globalThis.Buffer may not exist in workerd
  2. Buffer isn't in ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS

The fix normalises subclass constructor names to the nearest standard typed array parent in the reducer (not the reviver). This matches structured clone behaviour — Buffer is serialised as Uint8Array, which is what it extends.

This affects anyone passing a Buffer as a D1 bind parameter via getPlatformProxy() or the Miniflare API.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Bug fix with no API change

Open with Devin

Buffer extends Uint8Array but isn't available in all runtimes. The
ArrayBufferView reducer now normalises subclass constructor names to the
nearest allowed parent, fixing D1 blob binding via getPlatformProxy().

Fixes #5771
@ascorbic ascorbic requested a review from a team as a code owner February 10, 2026 15:14
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Feb 10, 2026
@claude
Copy link
Contributor

claude bot commented Feb 10, 2026

Claude finished @ascorbic's task —— View job


Changeset Review

All changesets look good

The changeset .changeset/fix-buffer-devalue.md has been validated:

  • Version Type: patch - Correct for a bug fix
  • Changelog Quality: Well-written description with clear explanation of the problem and solution
  • Markdown Headers: No h1/h2/h3 headers present
  • Format: Follows the conventional commit style ("fix: ...") which is acceptable per guidelines
  • Scope: Correctly targets only the miniflare package

The changeset clearly explains:

  • What the bug was (Buffer serialization failure)
  • Why it happened (Buffer isn't in allowed constructor list)
  • How it was fixed (normalize to standard typed array parent)
  • Technical context (matches structured clone behavior)

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 10, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12514

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12514

miniflare

npm i https://pkg.pr.new/miniflare@12514

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12514

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12514

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12514

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12514

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12514

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12514

wrangler

npm i https://pkg.pr.new/wrangler@12514

commit: fab4e2d

@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: fab4e2d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

devin-ai-integration[bot]

This comment was marked as resolved.

ascorbic and others added 2 commits February 11, 2026 07:01
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

🐛 BUG: D1 via miniflare doesn't accept Buffer type for blobs

1 participant

Comments