Skip to content

Commit

Permalink
fix(cloudflare): fix the node wrapper (#664)
Browse files Browse the repository at this point in the history
Returns the response converted from the internal event. 
It fixes a "This ReadableStream did not return bytes" workerd error.

Co-authored-by: conico974 <nicodorseuil@yahoo.fr>
  • Loading branch information
vicb and conico974 authored Dec 3, 2024
1 parent 4d328e3 commit 8ab921f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/giant-parrots-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

fix(cloudflare): fix the node wrapper
6 changes: 5 additions & 1 deletion packages/open-next/src/overrides/wrappers/cloudflare-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ const handler: WrapperHandler<InternalEvent, InternalResult> =
responseHeaders.append("Set-Cookie", cookie);
}

const { readable, writable } = new TransformStream();
const { readable, writable } = new TransformStream({
transform(chunk, controller) {
controller.enqueue(Uint8Array.from(chunk.chunk ?? chunk));
},
});
const response = new Response(readable, {
status: statusCode,
headers: responseHeaders,
Expand Down

0 comments on commit 8ab921f

Please sign in to comment.