From dc8b71cfbf0e56c2175f441a2e21411b474a3770 Mon Sep 17 00:00:00 2001 From: cirospaciari Date: Sun, 14 Apr 2024 22:48:36 -0300 Subject: [PATCH] call cancel instead of done --- src/bun.js/webcore/body.zig | 2 +- test/js/bun/http/body-leak-test-fixture.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bun.js/webcore/body.zig b/src/bun.js/webcore/body.zig index a41de5a632ec33..2659cc1ec16c9f 100644 --- a/src/bun.js/webcore/body.zig +++ b/src/bun.js/webcore/body.zig @@ -852,7 +852,7 @@ pub const Body = struct { bun.default_allocator, ); } - readable.done(global); + readable.abort(global); locked.readable.deinit(); } // will be unprotected by body value deinit diff --git a/test/js/bun/http/body-leak-test-fixture.ts b/test/js/bun/http/body-leak-test-fixture.ts index a51e1f0c1c308b..c3f51f4a6c2ad5 100644 --- a/test/js/bun/http/body-leak-test-fixture.ts +++ b/test/js/bun/http/body-leak-test-fixture.ts @@ -21,8 +21,10 @@ const server = Bun.serve({ } } else if (req.url.endsWith("/incomplete-streaming")) { const reader = req.body?.getReader(); - // we will receve ABORT_ERR here so we just catch it and ignores it - reader?.read().catch(() => {}); + if (!reader) { + // we will receive ABORT_ERR here so we just catch it and ignores it + reader?.read().catch(() => {}); + } } return new Response("Ok"); },