Skip to content

Commit 2322c4d

Browse files
committed
fix: Request constructor override
Use ReadableStream.from instead of Readable.toWeb The latter triggers a "This ReadableStream is disturbed" error See cloudflare/workerd#3245
1 parent 7202a2a commit 2322c4d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/cloudflare/src/cli/build/bundle-server.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ fetch = globalThis.fetch;
109109
const CustomRequest = class extends globalThis.Request {
110110
constructor(input, init) {
111111
if (init) {
112-
delete init.cache;
113-
if (init.body?.__node_stream__ === true) {
112+
init = {
113+
...init,
114+
cache: undefined,
114115
// https://github.com/cloudflare/workerd/issues/2746
115-
init.body = __cf_stream.Readable.toWeb(init.body);
116-
}
116+
// https://github.com/cloudflare/workerd/issues/3245
117+
body: init.body instanceof __cf_stream.Readable ? ReadableStream.from(init.body) : init.body,
118+
};
117119
}
118120
super(input, init);
119121
}

0 commit comments

Comments
 (0)