From 477918cf5ad188aaff3f6435320ad1d586dfeb94 Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Tue, 1 Sep 2026 08:07:18 +0000 Subject: [PATCH] :recycle: Support Deno 2 Response typing --- examples/server.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/server.ts b/examples/server.ts index 7ae69d3..a8265f8 100644 --- a/examples/server.ts +++ b/examples/server.ts @@ -135,7 +135,11 @@ export async function handleRequest(request: Request): Promise { }); const gif = dataUrlToBytes(dataUrl); - return new Response(request.method === "HEAD" ? null : gif, { + // Deno 2's Response type requires a Uint8Array backed by an ArrayBuffer. + // Copying preserves the GIF bytes while making the body valid in Deno 1 and 2. + const responseBody = request.method === "HEAD" ? null : new Uint8Array(gif); + + return new Response(responseBody, { status: 200, headers: { ...commonHeaders,