aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Ciro Spaciari <ciro.spaciari@gmail.com> 2023-09-26 23:31:20 -0300
committerGravatar GitHub <noreply@github.com> 2023-09-26 19:31:20 -0700
commit648d5aecf3980997c0672746374068033e632e1d (patch)
tree980fb11edcda91ad6d92a68c7f7525d4d8b28a10 /test
parentdc55492698326a668d730970f16e61728b83bb1a (diff)
downloadbun-648d5aecf3980997c0672746374068033e632e1d.tar.gz
bun-648d5aecf3980997c0672746374068033e632e1d.tar.zst
bun-648d5aecf3980997c0672746374068033e632e1d.zip
fix server end of stream, fix fetch not streaming without content-length or chunked encoding, fix case when stream do not return a promise on pull (#6086)
Diffstat (limited to 'test')
-rw-r--r--test/js/web/fetch/body-stream.test.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/js/web/fetch/body-stream.test.ts b/test/js/web/fetch/body-stream.test.ts
index 8e2baf92a..8f7675528 100644
--- a/test/js/web/fetch/body-stream.test.ts
+++ b/test/js/web/fetch/body-stream.test.ts
@@ -13,6 +13,35 @@ var port = 0;
];
const useRequestObjectValues = [true, false];
+ test("Should not crash when not returning a promise when stream is in progress", async () => {
+ var called = false;
+ await runInServer(
+ {
+ async fetch() {
+ var stream = new ReadableStream({
+ type: "direct",
+ pull(controller) {
+ controller.write("hey");
+ setTimeout(() => {
+ controller.end();
+ }, 100);
+ },
+ });
+
+ return new Response(stream);
+ },
+ },
+ async url => {
+ called = true;
+ expect(await fetch(url).then(res => res.text())).toContain(
+ "Welcome to Bun! To get started, return a Response object.",
+ );
+ },
+ );
+
+ expect(called).toBe(true);
+ });
+
for (let RequestPrototypeMixin of BodyMixin) {
for (let useRequestObject of useRequestObjectValues) {
describe(`Request.prototoype.${RequestPrototypeMixin.name}() ${