diff options
Diffstat (limited to 'test/js/web/fetch')
-rw-r--r-- | test/js/web/fetch/body-stream.test.ts | 29 |
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}() ${ |