perf(router): Use .bind to avoid holding other closures in memory

In many JS runtimes all closures created in the same scope share a context
this means that data held in one of the closures is not collected until all of the closures are collected.
This change prevents the returned promise from holding a reaction that holds the entire `Router` object in memory.
This commit is contained in:
David Neil
2026-02-02 10:35:44 -07:00
committed by Leon Senft
parent 5a0f272519
commit 3867cd8554
+2 -3
View File
@@ -697,9 +697,8 @@ export class Router {
// Make sure that the error is propagated even though `processNavigations` catch
// handler does not rethrow
return promise.catch((e: any) => {
return Promise.reject(e);
});
// perf: Use `.bind` to avoid holding the other closures in this scope while this promise is unsettled.
return promise.catch(Promise.reject.bind(Promise));
}
}