-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to reset an AbortSignal.timeout #1263
Comments
Just using setTimeout + AbortController manually for this case seems fine? |
Perhaps, and is how I've addressed this previously, it just feels a bit... awkward. I mean, that same thing could have been said about |
|
What is the issue with the DOM Standard?
The
AbortSignal.timeout(...)
method provided us with a nice functional mechanism to abort an operation after a given period of time and was quite a welcome addition. However, there is one use case that it currently does not quite adequately cover: idle timeouts. That is, given a long running operation, the ability to timeout only if there is not regular activity within a given period of time. If there is activity, the timeout resets.For example, let's imagine that we have an async iterable like a
ReadableStream
. Once we start consuming the stream, we want to make sure that each read happens within about one second and that the stream is canceled if the reads do not occur fast enough. This would be difficult withAbortSignal.timeout(...)
currently without being forced to create a newAbortSignal
on every iteration, which seems wasteful. Instead, it would be nice to have a singleAbortSignal
timeout that can be reset.Obviously, however, this becomes a bit weird to have an
update()
method onAbortSignal
instances created in other ways that does not do anything, so I'm not that worried about exactly what the api looks like... I'd mostly like to explore if this use case (specifically, allowing a single timeout-basedAbortSignal
to have it's timer reset) would be interesting.The text was updated successfully, but these errors were encountered: