- From: James Browning <notifications@github.com>
- Date: Thu, 29 Jun 2023 05:21:50 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/fetch/issues/1287/1613064011@github.com>
So `AbortSignal.any` has been merged but I don't believe the changes from `AbortSignal.any` actually do anything to affect the cleanup of the associated abort steps for fetch.
Like consider the following code:
```js
const abortController = new AbortController();
const res = await fetch("https://example.com", { signal: abortController.signal });
const text = await res.text();
// abort algorithms should become collectable around HERE
// ...sometime later
abortController.abort();
```
now we would want the fetch's abort algorithm to become collectable sometime around where is marked `HERE` given that `signal` can no longer affect body. However the spec says:
> A non-[aborted](https://dom.spec.whatwg.org/#abortsignal-aborted) [dependent](https://dom.spec.whatwg.org/#abortsignal-dependent) [AbortSignal](https://dom.spec.whatwg.org/#abortsignal) object must not be garbage collected while its [source signals](https://dom.spec.whatwg.org/#abortsignal-source-signals) is non-empty and it has registered event listeners for its [abort](https://dom.spec.whatwg.org/#eventdef-abortsignal-abort) event or its [abort algorithms](https://dom.spec.whatwg.org/#abortsignal-abort-algorithms) is non-empty.
and these conditions are met, the internal `requestObject.[[signal]]` created during `fetch()` has a non-empty source signal list consisting of `[abortController.signal]` AND it has an abort algorithm which is is added [by step 11](https://fetch.spec.whatwg.org/#dom-global-fetch).
(NOTE: `requestObject` is collectable as far as I can tell, however it's `[[signal]]` is not).
Note that this means as long as `abortController.signal` is retained, so will the abort algorithm. The fix here would be to remove the abort algorithm once the body is consumed (is sooner possible?).
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1287#issuecomment-1613064011
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/fetch/issues/1287/1613064011@github.com>
Received on Thursday, 29 June 2023 12:21:56 UTC