Skip to content

Commit 700888e

Browse files
fix(client): avoid memory leak with abort signals
1 parent 15cb7cf commit 700888e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,10 @@ export class Dedalus {
632632
controller: AbortController,
633633
): Promise<Response> {
634634
const { signal, method, ...options } = init || {};
635-
if (signal) signal.addEventListener('abort', () => controller.abort());
635+
const abort = controller.abort.bind(controller);
636+
if (signal) signal.addEventListener('abort', abort, { once: true });
636637

637-
const timeout = setTimeout(() => controller.abort(), ms);
638+
const timeout = setTimeout(abort, ms);
638639

639640
const isReadableBody =
640641
((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||

0 commit comments

Comments
 (0)