mirror of
https://github.com/angular/angular.git
synced 2026-11-23 07:05:14 -05:00
httpResource registers an 'abort' listener on the resource's AbortSignal
to unsubscribe the underlying request when it's cancelled. The listener
was only removed from the subscription's own error/complete callbacks,
but calling sub.unsubscribe() directly - which is exactly what happens
when the listener itself fires - doesn't trigger those callbacks. So on
the one path where the signal actually aborts, the listener was never
removed.
Passing { once: true } lets the removal happen automatically once the
listener fires, covering that path without touching the existing
error/complete cleanup, which is still needed for the paths where the
request finishes without ever aborting.
This also happens to route around a real leak on affected engines: an
AbortSignal that's had any listener attached isn't garbage collected
until it fires. https://bugs.webkit.org/show_bug.cgi?id=298499
(cherry picked from commit 5128dec0ca)