Re: [whatwg/dom] Ability to wait for async abort algorithms? (Issue #1389)

saschanaz left a comment (whatwg/dom#1389)

Hmm, I was thinking more about addEventListener-ish "keep working until you get the abort signal" situation. Suppose something like:

```js
while (!signal.aborted) {
  await write(serialize(data), { signal })
  await flush();
  sleep(10000)
}
```

And then somewhere else you do:

1. Abort the file write repeat
2. Upload the file

At step 2 you don't know whether the last write is flushed or not, because abort() doesn't wait for anything. (in this specific case you can probably call `flush()` again to make sure, though.)

What would be nicer (while the API addition is arbitrary and probably not nice enough)

```js
while (!signal.aborted) {
  signal.cleanup(() => flush());
  await write(serialize(data), { signal })
  sleep(10000)
}

// And then somewhere else:
// makes sure everything is aborted
await controller.abort()
```

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

Message ID: <whatwg/dom/issues/1389/3073055289@github.com>

Received on Tuesday, 15 July 2025 10:24:38 UTC