For Workers & Pages, what is the name of the domain?
your-worker-name.your-account.workers.dev
What is the issue or error you’re encountering
When querying a BLOB column from D1, the returned data is an Array instead of the documented ArrayBuffer. This violates the expected behavior stated in the D1 client API documentation.
What are the steps to reproduce the issue?
- Deploy the attached Worker (+ bind to DB).
- Send any HTTP request to the Worker endpoint.
- Observe the response:
{ "expected": "ArrayBuffer", "actual": "Array", // Incorrect type "isCorrect": false, "documentation": "https://developers.cloudflare.com/d1/platform/client-api/#type-conversion" }
`export default {
async fetch(request, env) {
// 1. Create a table with a BLOB column
await env.DB.exec(“CREATE TABLE IF NOT EXISTS test_blob ( id INTEGER PRIMARY KEY, data BLOB );”);
// 2. Insert test data (ArrayBuffer)
const testData = new Uint8Array([1, 2, 3]).buffer;
await env.DB.prepare("INSERT INTO test_blob (data) VALUES (?)").bind(testData).run();
// 3. Read the data back
const result = await env.DB.prepare("SELECT data FROM test_blob LIMIT 1").first();
// 4. Validate the data type
const isArrayBuffer = result?.data instanceof ArrayBuffer;
const constructorName = result?.data?.constructor?.name || "undefined";
return new Response(
JSON.stringify({
expected: "ArrayBuffer",
actual: constructorName,
isCorrect: isArrayBuffer,
documentation: "https://developers.cloudflare.com/d1/platform/client-api/#type-conversion"
}),
{ headers: { "Content-Type": "application/json" } }
);
}
};`