perf: use .abort.bind() instead of arrow closures to prevent memory leaks (#7174)
This commit is contained in:
committed by
Peter Steinberger
parent
d637a26350
commit
d9c582627c
@@ -15,7 +15,7 @@ export async function fetchWithTimeout(
|
||||
fetchFn: typeof fetch = fetch,
|
||||
): Promise<Response> {
|
||||
const controller = new AbortController();
|
||||
const timer = setTimeout(() => controller.abort(), Math.max(1, timeoutMs));
|
||||
const timer = setTimeout(controller.abort.bind(controller), Math.max(1, timeoutMs));
|
||||
try {
|
||||
return await fetchFn(url, { ...init, signal: controller.signal });
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user