You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently it's not straightforward to track whether all abort algorithms are finished. You would call AbortController.abort and then would hope it that things are aborted, before starting anything new. It's okay to do so when the new job never clashes with the previous supposed-to-be-aborted job (like some simple fetch() calls), but might clash if the abort algorithm includes closing a file handle, etc.
Would be nice if abort event had something like ExtendableEvent.waitUntil.
Perhaps? But that means "the thing" can't purely use AbortSignal internally but need to implement something else, if "the thing" is also aborting its downstream.
I suppose. If you define async getData that takes a signal. And internally it uses async getDataInternal that also takes a signal. It could pass the outer signal to getDataInternal and await getDataInternal to see if it gets an AbortError or some kind of success and based on that decide to return or throw for getData. It's a choice of course whether it wants to wait for getDataInternal, but there's nothing we can really do about that I think.
Hmm, I was thinking more about addEventListener-ish "keep working until you get the abort signal" situation. Suppose something like:
while(!signal.aborted){awaitwrite(serialize(data),{ signal })awaitflush();sleep(10000)}
And then somewhere else you do:
Abort the file write repeat
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)
while(!signal.aborted){signal.cleanup(()=>flush());awaitwrite(serialize(data),{ signal })sleep(10000)}// And then somewhere else:// makes sure everything is abortedawaitcontroller.abort()
Activity
annevk commentedon Jul 15, 2025
Isn't this tracked by the thing you are aborting? It should return an AbortError at some point.
Also, if this is proposing something new, any reason to not follow the template?
saschanaz commentedon Jul 15, 2025
Perhaps? But that means "the thing" can't purely use AbortSignal internally but need to implement something else, if "the thing" is also aborting its downstream.
Selected a wrong template 🤦🏻♀️
annevk commentedon Jul 15, 2025
I suppose. If you define
async getDatathat takes a signal. And internally it usesasync getDataInternalthat also takes a signal. It could pass the outer signal togetDataInternaland awaitgetDataInternalto see if it gets an AbortError or some kind of success and based on that decide to return or throw forgetData. It's a choice of course whether it wants to wait forgetDataInternal, but there's nothing we can really do about that I think.saschanaz commentedon Jul 15, 2025
Hmm, I was thinking more about addEventListener-ish "keep working until you get the abort signal" situation. Suppose something like:
And then somewhere else you do:
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)