Re: [whatwg/fetch] Proposal: fetch with multiple AbortSignals (#905)

@jakearchibald there is a memory leak if a not-first signals has already been aborted.

The fix:

```ts
function anySignal(signals: Iterable<AbortSignal>): AbortSignal {
  const controller = new AbortController();

  for (const signal of signals) {
    if (signal.aborted) {
        controller.abort(signal.reason); // add this
        return signal;
    }

    signal.addEventListener("abort", () => controller.abort(signal.reason), {
      signal: controller.signal,
    });
  }

  return controller.signal;
}
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/905#issuecomment-1586972104
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/905/1586972104@github.com>

Received on Monday, 12 June 2023 09:42:02 UTC